On Wed, Oct 17, 2007 at 10:22:58AM +0200, Mark Overmeer
wrote:
> Hum... the error report was even more right than I
expected it to be...
> After a long bug-hunt, I figured out that it is not
'-w' itself which
> is misbehaving (the file test flags), but it is the
module 'filetest'.
>
> The following script reports 'directory' twice:
>
> #!/usr/local/bin/perl5.10.0
> use filetest 'access';
>
> -d '/etc';
> -w '/etc/passwd';
> warn -f _ ? "filen" :
"directoryn";
> warn -d _ ? "directoryn" :
"filen";
>
> Apparently, -r/-w/-x/-R/-W/-X implemented in filetest
to not
> set '_' anymore, where they did so in perl5.8.8
On Fri, Oct 19, 2007 at 02:20:26AM +0200, Andreas J. Koenig
wrote:
> Change 19392 by jhi kosh on 2003/05/03
05:33:04
>
> Salvage 'use filetest "access"' from
compiletime to runtime.
It seems that Jarkko actually fixed a bug here - I'd infer
that access() wasn't
being called when it was expected that it would be.
I don't believe that the current behaviour is a behavioural
bug.
The documentation could be clearer, however.
It is documented that _ is set to the last stat.
It is documented that under filetest, -r/-w/-x/-R/-W/-X use
access() rather
than the mode bits from the file.
Hence one does not need to call stat(), so perl does not.
*That*
implementation efficiency is not documented.
So I think that the current behaviour is preferable. If we
changed it so that
-r/-w/-x/-R/-W/-X also call stat() as well as access(), then
we give everyone
inefficiency that they can't avoid. Whereas the current
behaviour is merely
caveat emptor on anyone wishing to take advantage of the _
filehandle.
I'm curious - on a modern Unix system with decent OS
caching, how much does
not calling stat again really save?
Nicholas Clark
|