lokiloki has asked for the wisdom of the Perl Monks concerning the following question:
This works perfectly fine on most of the machines I try it on. However, it does NOT work on SOME machines where $bytes is greater than the size of the file. I.e., if the file is 10kb and I ask to read the last 100kb it returns "nothing" on some servers, while on others it works.$bytes = 100000; open (FILE, 'somefile.data'); seek (FILE, -$bytes, 2); while (<FILE>) { print $_; } close FILE;
I tried to add the following, thinking that the aforementioned seek would return "false" on those machines:
seek (FILE, 0, 1) unless seek (FILE, -$bytes,2);
This didn't do anything. The same problem is occuring when I try to seek with a too large byte offset.
Can someone help?
Thanks...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: problem using seek on some systems
by ikegami (Patriarch) on Dec 06, 2006 at 21:47 UTC | |
by tye (Sage) on Dec 06, 2006 at 22:42 UTC | |
by Anonymous Monk on Dec 06, 2006 at 23:32 UTC | |
by lokiloki (Beadle) on Dec 06, 2006 at 22:00 UTC | |
by ikegami (Patriarch) on Dec 06, 2006 at 22:59 UTC | |
|
Re: problem using seek on some systems
by swampyankee (Parson) on Dec 06, 2006 at 21:58 UTC |