MooseX::Iterator::Locate - read "locate" database with MooseX::Iterator


File-Locate-Iterator documentation  | view source Contained in the File-Locate-Iterator distribution.

Index


NAME

Top

MooseX::Iterator::Locate -- read "locate" database with MooseX::Iterator

SYNOPSIS

Top

 use MooseX::Iterator::Locate;
 my $it = MooseX::Iterator::Locate->new;
 while ($it->has_next) {
   print $it->next, "\n";
 }

CLASS HIERARCHY

Top

MooseX::Iterator::Locate is a subclass of Moose::Object and File::Iterator::Locate,

    Moose::Object
    File::Iterator::Locate
      MooseX::Iterator::Locate

and has roles

    MooseX::Iterator::Role

DESCRIPTION

Top

MooseX::Iterator::Locate reads a "locate" database file in MooseX::Iterator style. It's implemented as a front-end to File::Locate::Iterator.

See examples/moosex-iterator.pl in the File-Locate-Iterator sources for a simple complete program.

FUNCTIONS

Top

$it = MooseX::Iterator::Locate->new (key=>value,...)

Create and return a new MooseX::Iterator::Locate object. Optional key/value pairs are passed to File::Locate::Iterator->new.

    my $it = MooseX::Iterator::Locate->new
               (suffixes => ['.pm', '.pl']);

$entry = $it->next

Return the next entry from the database. The first call is the first entry.

$entry = $it->peek

Return the next entry from the database, but don't advance the iterator position. This is what $it->next would return.

(This is not the same as peek in the base MooseX::Iterator version 0.11, it gives the second next item. Believe that's a mistake there, though the intention will be to follow what the base does when resolved.)

$bool = $it->has_next

Return true if there's a next entry available.

$it->reset

Move $it back to the start of the database again. The next call to $it->next gives the first entry again.

As discussed in File::Locate::Iterator under rewind(), this reset is only possible when the underlying database file or handle is a plain file or something seekable.

ATTRIBUTES

Top

The various parameters accepted by new are attributes. They're all "bare" create-only, no getters or setters.

    database_file     Str
    database_fh       FileHandle
    database_str      Str
    suffix            Str
    suffixes          ArrayRef[Str]
    glob              Str
    globs             ArrayRef[Str]
    regexp            Str | RegexpRef
    regexps           ArrayRef[Str|RegexpRef]
    use_mmap          enum default, if_sensible, if_possible, 0, 1

The default in the database_file attribute is per File::Locate::Iterator->default_database_file. (It's a coderef type since default_database_file looks at %ENV.)

SEE ALSO

Top

MooseX::Iterator, File::Locate::Iterator, Moose, Moose::Object

Moose::Manual::Roles

HOME PAGE

Top

http://user42.tuxfamily.org/file-locate-iterator/index.html

COPYRIGHT

Top


File-Locate-Iterator documentation  | view source Contained in the File-Locate-Iterator distribution.