Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Stat - returning undef values

by viffer (Sexton)
on Aug 02, 2013 at 03:10 UTC ( #1047529=perlquestion: print w/ replies, xml ) Need Help??
viffer has asked for the wisdom of the Perl Monks concerning the following question:

Hi all I am trying to obtain a time stamp using File::stat.

I am obtaining values in the array, but when I try and access individual fields they return undef.

my $filename = "$directory$file"; my @array=stat($filename);
returns
DB<2> x @array 0 File::stat=ARRAY(0x3055e8e4) 0 1638407 1 281494 2 33188 3 1 4 500 5 1231 6 0 7 97900 8 1375400720 9 1375371182 10 1375371182 11 4096 12 192
yet when I try and access a value in the array, via
my $time = $array[9];
it returns undef.

I have since found that

my $time = $array[0][9]
does indeed return the value "1375371182"

Similarly when using

my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime +,$blksize,$blocks) = stat($filename);
stat returns undef in all fields.

I kind of get that it's returned a two dimensional array, but I don't really follow why the code above doesn't appear to work?

hellllp! :)

Thanks Kev

Comment on Stat - returning undef values
Select or Download Code
Replies are listed 'Best First'.
Re: Stat - returning undef values (NOT)
by Anonymous Monk on Aug 02, 2013 at 03:37 UTC
    You're not dealing with stat, you're dealing with File::stat, their usages are different
      Thanks - deleted the use File::stat line and all works.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2015-07-08 08:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (96 votes), past polls