Hello mr19,

The monks have already answered your question. But you can also pass stat values to an array:

Sample:

#!/usr/local/bin/perl use strict; use warnings; use Data::Dumper; my $filename = 'test.txt'; my @array = stat($filename); print Dumper \@array; my $epoch_timestamp = (stat($filename))[9]; print "Epoch seconds: " . $epoch_timestamp . "\n"; __DATA__ $VAR1 = [ 64513, 7741435, 33188, 1, 283683, 6856, 0, 0, 1434023984, 1434023978, 1434023983, 4096, 0 ]; Epoch seconds: 1434023978

Or if you want to use the module:

#!/usr/local/bin/perl use strict; use warnings; use Data::Dumper; my $filename = 'test.txt'; my @array = stat($filename); print Dumper \@array; my $epoch_timestamp = (stat($filename))[9]; my $timestamp = localtime($epoch_timestamp); print "\nEpoch seconds: " . $epoch_timestamp . "\n"; print "Date and time: " . $timestamp . "\n"; statSubRoutine(); sub statSubRoutine { use File::stat; my $timestamp = (stat($filename)->mtime); my $localTimeStamp = localtime($epoch_timestamp); print "\n\$timestamp: " . $timestamp . "\n"; print "\$localTimeStamp: " . $localTimeStamp . "\n"; } __DATA__ $VAR1 = [ 64513, 7741354, 33188, 1, 283683, 6856, 0, 0, 1434028480, 1434028479, 1434028479, 4096, 0 ]; Epoch seconds: 1434028479 Date and time: Thu Jun 11 15:14:39 2015 $timestamp: 1434028479 $localTimeStamp: Thu Jun 11 15:14:39 2015

Update: Including conversion epoch seconds to human readable form.

Hope this helps.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re: Problem with file::stat by thanos1983
in thread Problem with file::stat by mr19

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.