On Tuesday 11 December 2007 15:53, [EMAIL PROTECTED] wrote:
>
> John W.Krahn <[EMAIL PROTECTED]> writes:
> >
> > 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'.
>
> As you've no doubt noticed, I'm not the brightest bulb on the tree. I
> didn't really understand what that meant until your insistence it was
> available. Even now I'm not sure what is meant by `imported
> separately or using the tags :seek and :mode to import. Apparently
> some other syntax I have yet to try.... I'll experiment until I get
> that right later, but using: `
>
> use Fcntl :seek;
$ perl -ce'use Fcntl :seek;'
syntax error at -e line 1, near "use Fcntl :"
-e had compilation errors.
perldoc -f use
use Module VERSION LIST
use Module VERSION
use Module LIST
use Module
use VERSION
After the module name, which has to be a bareword, must follow a
*list*, which cannot be barewords.
> fails if either SEEK_SET or SEEK_CUR are used in seek(). Whereas it
> works as expected if SEEK_END is put into seek();
It looks as if the SEEK_* constants are not being imported correctly.
A bareword will be treated as a string which will evaluate to 0 in
numerical context so if one of them is supposed to be 0 it will always
work.
You can also find the SEEK_* constants in the POSIX module.
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/