BaMo::Role::FileIO - File input & ouput interface for parser classes
use Mouse; with 'BaMo::Role::FileIO'; sub parse { my ($self) = @_; $fhi = $self->_fhi; while(my $line = $fhi->()) { #parse a bit if($line =~ /break/) { # oh no, we parsed too much... push @{$self->_cached_records}, $line; #but we can reverse it } } }
Enhances the class that uses this role with a file handle iterator that is capable of caching records (lines in most cases), in case you read too much.
Get or set the filehandle.
You can push lines on @{$self->_cached_records} (they need to be chomped already). The file handle iterator will use them first if you call it. The file handle will not be touched until all cached lines are shifted.
Opens the file in the specified mode. Sets the fh and _fhi attribute (indirectly).
fh
_fhi
Get the file handle iterator.
Close the filehandle.
jw bargsten, <joachim.bargsten at wur.nl>
<joachim.bargsten at wur.nl>
To install Bio::Gonzales, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bio::Gonzales
CPAN shell
perl -MCPAN -e shell install Bio::Gonzales
For more information on module installation, please visit the detailed CPAN module installation guide.