The tell Function returns the current byte position in the file : tell « File « Perl






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;

   
    
    
    
  








Related examples in the same category

1.The tell function returns the current byte position of a filehandle.
2.Using tell function to check a file handle