in reply to "The stat preceding -l _ wasn't an lstat"?

Maybe it depends on whether the last stat was successful or not? That is, if sysinfo.pl doesn't exist, your code gives me no problems, printing FooBar. But, on the same machine, if I then touch sysinfo.pl, I get the error message you complain about. Perhaps perl can't tell the difference between an unsuccessful stat and an unsuccessful lstat, when using "-l _" because it's just not stored?

  • Comment on Re: "The stat preceding -l _ wasn't an lstat"?

Replies are listed 'Best First'.
Re^2: "The stat preceding -l _ wasn't an lstat"?
by Burak (Chaplain) on Jan 17, 2010 at 21:32 UTC
    You're right I guess. Btw, I'm doing -f $file && ! -l $file (double call) now to prevent this error.

      Just reverse it, and it's ok. ! -l $file && -f _. The -f flag can work on lstat's output, whether the lstat found a link or not.