Blob


1 #!/usr/bin/perl
3 # Make a program to identify the oldest file named on the command line and report its age in days. What does it do if the list is empty? (That is, if no files are mentioned on the command line.)
5 use v5.24;
6 use warnings;
7 use strict;
8 use utf8;
10 sub filetest {
11 shift;
12 printf ("%20s: ", $_);
13 my $attribs;
14 if (! -e) {
15 return "(non-existent)\n";
16 }
17 if (-r) {
18 $attribs .= "r";
19 } else {
20 $attribs .= "-";
21 }
22 if (-w) {
23 $attribs .= "w";
24 } else {
25 $attribs .= "-";
26 }
27 if (-x) {
28 $attribs .= "x";
29 } else {
30 $attribs .= "-";
31 }
32 return $attribs;
33 }
35 foreach (@ARGV) {
36 print(filetest($_)."\n");
37 }