File-Locate-Iterator
view release on metacpan or search on metacpan
devel/handle.pl view on Meta::CPAN
print <FH>;
exit 0;
}
1;
__END__
=for stopwords filename filenames filesystem slocate filehandle arrayref mmap mmaps seekable PerlIO mmapped XSUB coroutining fd Findutils Ryde wildcard charset wordsize wildcards
=head1 NAME
File::Locate::Iterator::TieHandle -- file handle tied to read "locate" database
=head1 SYNOPSIS
use File::Locate::Iterator::TieHandle;
tie *FH, 'File::Locate::Iterator::TieHandle';
while (defined (my $line = <FH>)) {
lib/File/Locate/Iterator.pm view on Meta::CPAN
return $self->{'entry'};
} else {
return;
}
}
1;
__END__
=for stopwords filename filenames filesystem slocate filehandle arrayref mmap mmaps seekable PerlIO mmapped XSUB coroutining fd Findutils Ryde wildcard charset wordsize wildcards Taintedness taintedness untaint ie
=head1 NAME
File::Locate::Iterator -- read "locate" database with an iterator
=head1 SYNOPSIS
use File::Locate::Iterator;
my $it = File::Locate::Iterator->new;
while (defined (my $entry = $it->next)) {
lib/File/Locate/Iterator.pm view on Meta::CPAN
=head1 OTHER WAYS TO DO IT
C<File::Locate> reads a locate database with callbacks instead. Whether you
want callbacks or an iterator is generally a matter of personal preference.
Iterators let you write your own loop, and can have multiple searches in
progress simultaneously.
The speed of an iterator is about the same as callbacks when
C<File::Locate::Iterator> is built with its XS code.
Iterators are good for cooperative coroutining like C<POE> or C<Gtk> where
state must be held in some sort of variable to be progressed by calls from
the main loop. Note that C<next()> will block on reading from the database,
so the database should generally be a plain file rather than a socket or
something, so as not to hold up a main loop.
If you have the recommended C<File::Map> module then iterators share an
C<mmap()> of the database file. Otherwise the database file is a separate
open handle in each iterator, meaning a file descriptor and PerlIO buffering
each. Sharing a handle and having each seek to its desired position would
be possible, but a seek drops buffered data so would be slower. Maybe some
( run in 0.294 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )