#Format: #tell(FILEHANDLE); #tell; #!/usr/bin/perl open(FH,"db") || die "Can't open: $!\n"; while ($line=<FH>) { chomp($line); if ($line =~ /^Tom/) { $currentpos=tell; print "position: $currentpos.\n"; print "$line\n\n"; } } seek(FH,$currentpos,0); @lines=(<FH>); print @lines;