#!usr/bin/perl
use strict;
####
# This is a program which reads in a list of file names from the command
# line and prints which files are readable, writable and/or executable,
# and whether each file exists.
##
##
while ($i < scalar(@ARGV)) {
open(MYFILE, $ARGV[$i]) or die("Error: cannot open file '$ARGV[$i]'\n");
##
##
print "$ARGV[$i] is readable!\n" if -r MYFILE;
print "$ARGV[$i] is writable!\n" if -w MYFILE;
print "$ARGV[$i] is executable!\n" if -x MYFILE;
print "$ARGV[$i] exists!\n" if -e MYFILE;
$i++;
##
##
} # end while
##
##
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
for my $file (@ARGV) {
-e $file or next;
say "`$file' exists!";
say "`$file' is ", ( $_->[1]() ? "" : "not " ), $_->[0]
for [readable => sub () { -r _ }],
[writable => sub () { -w _ }],
[executable => sub () { -x _ }];
}
__END__