#!/usr/bin/env perl use strict; use warnings; use Cwd; use File::Find; my $cwd = getcwd(); my @dirs = map "$cwd/$_", qw{a b c}; print "--- READING ---\n"; find(\&wanted_to_read, @dirs); print "--- WRITING ---\n"; find(\&wanted_to_write, @dirs); sub wanted_to_read { if (! -f $File::Find::name) { print "$File::Find::name is not a normal file.\n"; } elsif (-z _) { print "$File::Find::name is zero-length.\n"; } elsif (! -r _) { print "$File::Find::name is not readable.\n"; } else { print "OK to READ: $File::Find::name\n"; } return; } sub wanted_to_write { if (! -f $File::Find::name) { print "$File::Find::name is not a normal file.\n"; } elsif (! -r _) { print "$File::Find::name is not readable.\n"; } elsif (! -w _) { print "$File::Find::name is not writable.\n"; } else { print "OK to WRITE: $File::Find::name\n"; } return; }