On Tuesday 11 December 2007 14:09, [EMAIL PROTECTED] wrote: > > John W.Krahn <[EMAIL PROTECTED]> writes: > > > > use Fcntl ':seek'; > > > > seek FILE, -100, SEEK_END or die "Cannot seek on './myfile' $!"; > > Still seeing something I don't understand. Using a working version > of the code I posted (included at the end) telling seek to go to 100 > bytes before the byte count at eof. I see a small discrepancy in > where it actually goes of 5-15 bytes. > > I didn't use Fcntl ':seek' because it appears to lack the other two > operators (SEEK_SET, SEEK_CUR) referred to at perldoc -f seek.
perldoc Fcntl [ SNIP ] For ease of use also the SEEK_* constants (for seek() and sysseek(), e.g. SEEK_END) and the S_I* constants (for chmod() and stat()) are available for import. They can be imported either separately or using the tags `:seek' and `:mode'. perldoc -m Fcntl [ SNIP ] # Named groups of exports %EXPORT_TAGS = ( 'flock' => [qw(LOCK_SH LOCK_EX LOCK_NB LOCK_UN)], 'Fcompat' => [qw(FAPPEND FASYNC FCREAT FDEFER FDSYNC FEXCL FLARGEFILE FNDELAY FNONBLOCK FRSYNC FSYNC FTRUNC)], 'seek' => [qw(SEEK_SET SEEK_CUR SEEK_END)], Yes, the ':seek' label *does* include all three SEEK_* constants. You must be doing something wrong. > And it seems like what I really needed was SEEK_SET or (zero 0) as > shown at perldoc -f seek. Since using SEEK_END or (2) will give an > unpredictable seeking location because the amount of data entered > will vary every time (a real working version) of this script gets > used. > > So subtracting the original end of file byte cnt + 100 may not go > where we want to be. Seems like it would be better to tell seek to > go to 100 bytes before the original end of file byte count. So I had > that wrong originally too. > > That is what I'm attempting here but as mentioned above it appears to > show an additional offset of 12 bytes from somewhere: OS? > Im running Gentoo linux, I am not sure your example proves what you seem to think it is trying to prove and as you have not provided the contents of "myfile" I cannot run your example but I can see no discrepances in the code you posted. What exactly were you expecting it to do that it did not do? Or not do that you expected it to do? John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/