I'm disturbed because I don't understand how the subroutine used as its first parameter gets $_
The nice thing about open source is that you can take a look at the code, if you want to know how something is being done. In many cases, an educated guess what keywords to grep for is all that's needed to jump to the right place. In this case, when you search for $wanted_callback, you find something like this (there are several similar snippets):
$dir= $p_dir; # $File::Find::dir $name= $dir_name; # $File::Find::name $_= ($no_chdir ? $dir_name : $dir_rel ); # $_ # prune may happen here $prune= 0; { $wanted_callback->() }; # protect against wild "next"
As you can see, the callback routine is called without argument, but $_ (and other global variables) are populated before the call.
In reply to Re: File::Find and $_ in the wanted sub
by almut
in thread File::Find and $_ in the wanted sub
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |