in reply to FileHandle setpos function
Rather than getpos() and setpos(), I think you may have better luck with tell() and seek().
Maybe this (very contrived) example will give you ideas.
use strict; use warnings; use IO::File; use IO::Seekable; my $file = 'whatever.fil'; $/ =';'; my $fh = new IO::File; if ($fh->open("< $file")) { my $last = 0; while (<$fh>){ if ($_ =~ m|([^/]+/)|){ $fh->seek($last+$+[0],0); print $1,"\n"; }else{ print "$_\n"; } $last = $fh->tell; } $fh->close; }else{ die "$file not found. $!\n"; }
Minor update to remove some unnecessary cruft.
|
|---|