If I read what you wrote correctly, you want to pass a filename to a sub in another module and then later, be able to read the file one line at a time, right? If so, I think this might work:
package Foo;
use strict;
my $sep;
sub set_file {
my $file = shift;
$sep = shift || "\n";
open FH, "< $file" or die "Cannot open $file for reading: $!";
}
sub get_line {
local $/ = $sep;
my $temp = <FH>;
return $temp;
}
1;
In your main program:
use strict;
use Foo;
Foo::set_file( $some_file );
for ( 0..10 ) {
print Foo::get_line
};
If that's not what you're looking for, let us know. It seems to me that seek is not what you're needing here.
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats. |