in reply to Code review for magazine article?
Why are you adding a slash after the slash? According to the documentation:sub wanted { print OUT "$File::Find::dir/"; print OUT "$_\n"; }
$File::Find::dir = /some/path/ $_ = foo.ext $File::Find::name = /some/path/foo.ext
Other than for expository reasons, I would expect to see:
instead of mucking with leaning toothpicks.print OUT "$File::Find::name";
I would reformat this to see the parallels:###selection criteria is a set of easy Regular Expressions: foreach my $file1(@file1only) { unless (($file1 =~ "tmp") or ($file1=~"temp") or ($file1 =~ "recyc +ler") or ($file1 =~ "history")) { print OUT $file1; } }
And I would probably lose the lc in favor of m//i. Which, by the way, you can't say "temp"i, you have to use m"temp"i.###selection criteria is a set of easy Regular Expressions: foreach my $file1(@file1only) { unless (($file1 =~ "tmp") or ($file1 =~ "temp") or ($file1 =~ "recycler") or ($file1 =~ "history")) { print OUT $file1; } }
I'm pretty sure no one uses m// anymore unless they're avoiding toothpicks (m{/lib/dir}), or obfu-ing (m atempa).
Now, are you sure you want "temp"? Because that will match "lastemployee"also. Perhaps you need "^temp$" or "\btemp\b"?
Do you need the OUT filehandle on that last print?print OUT "LOWERCASING ALL FILE AND PATHNAMES BEFORE COMPARING.\n"; print "\n\n";
I would put something around the file names, to set them off. Perhaps 'Tmp' and 'Temp' instead?print OUT "IGNORING FILES WITH Tmp OR Temp IN PATHNAME.\n";
And are you comparing with the directory path, or the file path? Maybe the regex should be
Or maybe you want to rethink the output of InventoryReport.pl so that the filename is easy to split from the dir name, and then dotted together for the final output?$file1 =~ /\btemp\W\w)/; # temp is not the filename
-QM
--
Quantum Mechanics: The dreams stuff is made of
|
|---|