in reply to Re^2: reading a line from file two times
in thread reading a line from file two times
The above coed still prints the next line after using seek. am I missing something there in the seek function ?
The negative seek may not work in windows... not sure. It definitely does work on my linux box though. I don't have any windows handy or I'd test it. I did notice you didn't use "or die $!. " Most likely it would return an error result on your platform.
use strict; use Fcntl qw(:seek); open my $in, "filename" or die $!; my $line = <$in>; print "$line\n"; seek $in, (0 - length $line), SEEK_CUR or die $!; $line = <$in>; print "$line\n"; close $in;
It should either work or complain...
-Paul
|
|---|