When running the following code, the filenames of all files below C:\Test are printed. Why doesn't it print just Hello
(n times, depending on how many files are processed)?
Does this imply that I cannot rely on shift
to reliably assign to $_
? Imagine a coworker implements the wtf
function and doesn't know that it's called from a File::Find
wanted sub.
I run this code with Strawberry Perl 5.12
Edit: This code doesn't run as expected either:
use strict;
use warnings;
wanted();
sub wanted{
wtf("Hello");
}
sub wtf {
shift;
print; #expecting Hello
}
So I guess I'm totally off the highway here.. This has obviously nothing to do with File::Find, I'm now looking for a new title for this question. Here's my original code:
use strict;
use warnings;
use File::Find;
find(\&wanted, "C:\\test");
sub wanted{
wtf("Hello");
}
sub wtf {
shift;
print; #expecting Hello
}