in reply to seek function always returns true
So you just need to have that value, and check it against the number that the user provides as the offset to go to:my $current_file_size = -s $file_name;
Of course, if the user is asking for fixed-length-record $n, you'd want to say that the requested $n is greater than the number of records in the file (file size divided by record size, which, in an ideal world, would always be an integer value).if ( $start_pc >= $current_file_size ) { warn sprintf( "Your requested offset (%d) is past EOF (%d)\n", $start_pc, $current_file_size ); # and do something else, like prompt for new input }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: seek function always returns true
by rudyg123 (Initiate) on Jun 20, 2007 at 14:10 UTC |