Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

mtime from magic filehandle

by rootcho (Pilgrim)
on Feb 11, 2010 at 19:22 UTC ( [id://822735]=perlquestion: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://822735]
Approved by AnomalousMonk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-19 10:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found