foreach (@files) { next if( -d $_); open my $in_fh, '<', $_; ...rest of code... }