Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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);
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

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1047529]
Approved by 2teez
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (None)
    As of 2017-04-28 11:00 GMT
    Find Nodes?
      Voting Booth?
      I'm a fool:

      Results (521 votes). Check out past polls.