The tell function returns the current byte position of a filehandle. : tell « File « Perl






The tell function returns the current byte position of a filehandle.

    

#Format

#tell (FILEHANDLE);
#tell FILEHANDLE;
#tell;

open(PASSWD, "/etc/passwd") || die "Can't open: $!\n";
while ( chomp($line = <PASSWD>) ){
    if ( $line =~ /sync/){
       $current = tell;
       print "---$line---\n";
    }
}
printf "The position returned by tell is %d.\n", $current;
seek(PASSWD, $current, 0);
while(<PASSWD>){
    print;
}

   
    
    
    
  








Related examples in the same category

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