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"; }