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!