in reply to Re: Can the special underline filehandle (stat cache) be cleared?
in thread Can the special underline filehandle (stat cache) be cleared?

Yes, as mentioned in the OP, my current method of clearing _ is to do an lstat() on the empty string. I was hoping there was a "more correct" way to clear the stat cache, because, while some implementations of the lstat() system call do optimize a stat of the empty string to not bother going to the file system, I'm skeptical about that in the general case.

It is interesting to note that the file tests, such as -e do not exhibit the same behaviour, with respect to warnings, as stat() and lstat():

$ perl -we'-e _' $ perl -we'stat _' stat() on unopened filehandle _ at -e line 1.

That's a better solution than what I was using before, but I wonder if, as above, there's a "more correct" way to do it.

Cheers,

Replies are listed 'Best First'.
Re^3: Can the special underline filehandle (stat cache) be cleared? ("")
by tye (Sage) on Oct 04, 2006 at 03:51 UTC

    Note that calling lstat on an empty string on some systems will give you the same results as lstat("."). So this solution isn't portable.1

    - tye        

    1 Luckily, it isn't needed. Unluckily, I didn't notice that you were doing this before I replied with my better (IMO, at least) solution.