in reply to Regex and negative file test
Most likely because there is no file cica2061205.gz in the current directory. Or because the @| array contains something that makes the file match. Or something else. Why don't you try and break the regular expression down and sprinkle the code with debug messages to see closer what's going on?
# filter any unwholesome file names my @reason; push @reason, "... a file with that name doesn't exist" if ! -f $file; push @reason, "... it starts with a dot" if $file =~ /^\./; ... if (@reason) { warn "Rejecting filename '$file' because "; warn $_ for @reason; next; };
Also, it is a much saner approach to only allow what is permitted instead of rejecting what you know is bad. For example, I would simply just allow sane filenames, instead of trying to weed out not-so-sane filenames:
$file =~ /^\w[-_\w]+\.\w+$/ or push @reason, '... it doesn't look like a sane filename';
|
|---|