Blob


1 #!/usr/bin/perl
3 # Modify your answer to Exercise 2 to report the times using the
4 # YYYY-MM-DD format. Use a map with localtime and a slice to turn
5 # the epoch times into the date strings that you need. Note the
6 # localtime documentation about the year and month values it
7 # returns. Your report should look like this:
8 #
9 # fred.txt 2011-10-15 2011-09-28
10 # barney.txt 2011-10-13 2011-08-11
11 # betty.txt 2011-10-15 2010-07-24
13 use v5.24;
14 use warnings;
15 use strict;
16 use utf8;
18 foreach (glob '.* *') {
19 my ($atime, $mtime) = map {
20 my ($year, $mon, $day) = (localtime($_))[5,4,3];
21 sprintf "%4d-%02d-%02d", $year+1900, $mon, $day;
22 } (stat $_)[8,9];
23 printf ("%-16s %s %s\n", $_, $atime, $mtime);
24 }