NAME
Parse::CPAN::MirroredBy - Parse MIRRORED.BY
DESCRIPTION
Like the other members of the Parse::CPAN family Parse::CPAN::MirroredBy parses and processes the CPAN meta data file MIRRORED.BY.
METHODS
new
Creates a new, simple, parser object.
add_map
# Instead of the full hash just read the hostname
$parser->add_map( sub { $_[0]->{hostname} } );
The add_map
method adds a map stage to the filter pipeline.
A single element is passed into the provided function from the previous pipeline phase, and one or more values can be returned which will be passed on to the next pipeline phase.
Returns true if added, or throws an exception if a non-CODE reference is provided.
add_grep
# We only want the daily mirrors
$parser->add_grep( sub { $_[0]->{frequency} eq 'daily' } );
The add_grep
method adds a grep phase to the filter pipeline.
A single value is passed into the provided function, and the function should return true if the value is to be kept, or false if not.
Returns true if added, or throws an exception if a non-CODE reference is provided.
add_bless
# Bless into whatever objects
$parser->add_bless( 'Foo::Whatever' );
For situations in which you wish to convert the pipeline values into objects directly, and don't want to do it via a map phase that passes values into a contructor, the add_bless
method allows you to provide a class name that the elements of the pipe will be passed to.
parse_file
my @mirrors = $parser->parse_file( 'MIRRORED.BY' );
Once the parser is ready to process the file, the parse_file
method can be provided a file name to read. It will read the file, passing the contents through the filter pipeline, and returning the resulting values as a list of results.
parse
my @mirrors = $parser->parse( $file_handle );
Once the parser is ready to process the file, the parse
method can be provided a file handle to read. It will read from the file handle, passing the contents through the filter pipeline, and returning the resulting values as a list of results.
SUPPORT
Bugs should be reported via the CPAN bug tracker at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Parse-CPAN-MirroredBy
AUTHOR
Adam Kennedy <adamk@cpan.org>
SEE ALSO
Parse::CPAN::Authors, Parse::CPAN::Packages, Parse::CPAN::Modlist, Parse::CPAN::Meta
COPYRIGHT
Copyright 2008 Adam Kennedy.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.