rootcho has asked for the wisdom of the Perl Monks concerning the following question:

Hi is there a way to not just test "-X _", but also get other information stored from the last stat/lstat call.
What I'm looking for is (pseudo-code)
(_)[9]
thanx

Replies are listed 'Best First'.
Re: mtime from magic filehandle
by AnomalousMonk (Archbishop) on Feb 11, 2010 at 19:34 UTC

    Quoth  perldoc -f stat

    If "stat" is passed the special filehandle consisting of an underline, no stat is done, but the current contents of the stat structure from the last "stat", "lstat", or filetest are returned. Example: if (-x $file && (($d) = stat(_)) && $d < 0) { print "$file is executable NFS file\n"; }
Re: mtime from magic filehandle
by ikegami (Patriarch) on Feb 11, 2010 at 19:33 UTC

    You need to call stat if you want stat's results.

    $ perl -le'print((stat(".bashrc"))[9]);' 1244835383 $ perl -le'-x ".bashrc"; print((stat(_))[9]);' 1244835383