Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

stat a file

by pelos (Initiate)
on May 04, 2013 at 05:43 UTC ( #1031989=perlquestion: print w/ replies, xml ) Need Help??
pelos has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to get the time of the file or the size or any of the attributes of the file. after reading several examples and replicating the code I get a blank line =( been new to perl I am assuming that might be something I am doing, I am using active perl in windows 7
use File::stat; $mtime = (stat("C:/PC_Files/Dropbox/Beta/test.txt")); print $mtime[5];
doesn't matter what 0-13 stat I ask. but if I print the variable I get no [] I get
File::stat=ARRAY(0x3585c0)
thanks for the tips.

Comment on stat a file
Select or Download Code
Re: stat a file
by moritz (Cardinal) on May 04, 2013 at 05:50 UTC
      thanks I will give it a try. do you recommend to stick to one particular method? or doesn't really matter?

        stat has slightly less overhead, but File::stat is slightly more readable. File::stat is part of the Perl core since 5.004 (released 1997-05-15), so it's quite safe to assume that File::stat is available even on older Perl installations.

        File::stat has some minor problems, mainly with the implicit $_ and the special handle _, see "Bugs" in File::stat. Also, the filetest operators -t, -T, and -B are not implemented in File::stat. This is documented in "Errors".

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2014-07-14 11:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (257 votes), past polls