MS::Reader::XML - Base class for XML-based parsers
package MS::Reader::Foo; use parent MS::Reader::XML; sub _init {} sub _finalize{} package main; use MS::Reader::Foo; my $run = MS::Reader::Foo->new('run.foo'); while (my $record = $foo->next_record('bar') { # etc }
MS::Reader::XML is the base class for XML-based parsers in the package. The class and its methods are not generally called directly, but publicly available methods are documented below.
MS::Reader::XML
my $r = $parser->fetch_record($ref => $idx);
Takes two arguments (record reference and zero-based index) and returns a record object. The types of records available and class of the object returned depends on the subclass implementation.
while (my $r = $parser->next_record($ref);
Takes a single argument (record reference) and returns the next record in the parser, or undef if the end of records has been reached. Types of records available depend on the subclass implementation.
my $n = $parser->record_count($ref);
Takes a single argument (record reference) and returns the number of records of that type present. Types of records available depend on the subclass implementation.
my $i = $parser->get_index_by_id($ref => 'bar');
Takes two arguments (record reference and record ID) and returns the zero-based index associated with that record ID, or undef if not found. Types of records available and format of the ID string depend on the subclass implementation.
my $i = $parser->curr_index($ref);
Takes a single argument (record reference) and returns the zero-based index of the "current" record. This is similar to the "tell" function on an iterable filehandle and is generally used in conjuction with next_record.
next_record
$parser->goto($ref => $i);
Takes two arguments (record reference and zero-based index) and sets the current index position for that record reference. This is similar to the "seek" function on an iterable filehandle and is generally used in conjuction with next_record.
$parser->dump();
Returns a textual serialization of the underlying data structure (via Data::Dumper) as a string. This is useful for developers who want to access data details not available by accessor.
WARNING WARNING WARNING: This is a destructive process - don't try to use the object after dumping its contents!!!
The API is in alpha stage and is not guaranteed to be stable.
Please reports bugs or feature requests through the issue tracker at https://github.com/jvolkening/p5-MS/issues.
Jeremy Volkening <jdv@base2bio.com>
Copyright 2015-2016 Jeremy Volkening
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
To install MS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MS
CPAN shell
perl -MCPAN -e shell install MS
For more information on module installation, please visit the detailed CPAN module installation guide.