Mega Code Archive

 
Categories / Perl / File
 

The tell Function returns the current byte position in the file

#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;