My code looked like:
open FILE, "$filename" or die $!; flock(FILE,2); seek(FILE,0,2); @entries = <FILE>; flock(FILE,8);
Yet when I went to view the contents of @entries, it was empty. I scratched my head for hours on this one since all the examples of seek I had seen seemed to call it with (FILEHANDLE,0,2). Finally, I came to some sort of enlightenment thinking that since the whence portion of the seek statement was set to 2, the @entries list is only reading from the end of the FILEHANDLE on. When I changed the entry to seek(FILEHANDLE,0,0) the outcome was more what I expected.
So, I guess I am looking for someone with more experienced robes than mine to give me the nod that this logic is correct and the moral of "never blindly copy another's code" fits the bill.
humbly -c
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: seek(UNDERSTANDING);
by runrig (Abbot) on Aug 06, 2001 at 21:14 UTC | |
|
Re: seek(UNDERSTANDING);
by tadman (Prior) on Aug 10, 2001 at 05:25 UTC |