The patch is pretty trivial (minimal testing but don't see why it should not be stable). The value of $_ is saved and restored so you can change/use it in &wanted with impunity. Note as we are passing 3 values to the &wanted every time there will be a slowdown but this is probably (speculation) trivial compared to iterating over the directory tree.
$ diff Find.pm FindPatch.pm 1c1 < package File::Find; --- > package File::FindPatch; 394c394 < { &$wanted_callback }; # protect against wild "next" --- > { my $save=$_; &$wanted_callback($save,$name,$dir); $_=$ +save }; # protect against wild "next" 450c450 < { &$wanted_callback }; # protect against wild "next" --- > { my $save=$_; &$wanted_callback($save,$name,$dir); $_=$ +save }; # protect against wild "next" 495c495 < { &$wanted_callback }; # protect against wild "next" --- > { my $save=$_; &$wanted_callback($save,$name,$dir); $_ +=$save }; # protect against wild "next" 519c519 < { &$wanted_callback }; # protect against wild +"next" --- > { my $save=$_; &$wanted_callback($save,$name,$ +dir); $_=$save }; # protect against wild "next" 525c525 < { &$wanted_callback }; # protect against wild "nex +t" --- > { my $save=$_; &$wanted_callback($save,$name,$dir) +; $_=$save }; # protect against wild "next" $
cheers
tachyon
In reply to Re: When should a wheel be reinvented
by tachyon
in thread When should a wheel be reinvented
by fletcher_the_dog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |