Launcher::Cascade::FileReader::Seekable - a filereader that memorizes its position between reads.
use Launcher::Cascade::FileReader::Seekable; my $f = new Launcher::Cascade::FileReader -path => ... ; my $fh1 = $f->open(); my $line1 = <$fh1>; # first line $f->close(); # later, in a nearby piece of code my $fh2 = $f->open(); # different filehandle my $line2 = <$fh2>; # next line
Launcher::Cascade::FileReader::Seekable inherits from Launcher::Cascade::FileReader but keeps in memory the position where it was at when the filehandle is closed. Subsequent calls to open() will perform the necessary operations to resume reading where it last stopped, be it when reading a local file, or a remote file through ssh.
Stores the filehandle's position in the position() attribute, then closes the filehandle.
Opens the file (locally or remotely), seeks to the desired position() and returns a filehandle.
perl has to be in a directory mentioned in the PATH environment variable on the remote host, because the seek operation on remote files is performed with a Perl one-liner.
perl
PATH
seek
The memorization of the position is performed only when closing the filehandle through the close() method of Launcher::Cascade::FileReader::Seekable, not when closing the filehandle directly:
my $fh = $f->open(); ... # do something with it $f->close(); # right: position() is updated close $fh; # wrong: position() is *not* updated
Launcher::Cascade::FileReader
Cédric Bouvier <cbouvi@cpan.org>
<cbouvi@cpan.org>
Copyright (C) 2006 Cédric Bouvier, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'Cédric'. Assuming CP1252
To install Launcher::Cascade, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Launcher::Cascade
CPAN shell
perl -MCPAN -e shell install Launcher::Cascade
For more information on module installation, please visit the detailed CPAN module installation guide.