sub _all_readable { my $not_readable = 0; for my $file ( @_ ) { $not_readable++ if !-r $file; } return !$not_readable; } if ( _all_readable( @list_of_files ) ) { # action }