... or unlink on the fly, with the no_chdir option.
With no_chdir $File::Find::name and $_ are equivalent.
find( {wanted => \&wanted, no_chdir=>1}, @directories );
sub wanted {
my $wanted = -l && !-e;
push @msgs, $_ and $counter++ if $wanted;
return if $param{test} or !$wanted;
unlink or croak "Warning: couldn't unlink '$_' :$OS_ERROR\n";
return;
}
Update
Refactored wanted function.
print+qq(\L@{[ref\&@]}@{['@'x7^'!#2/"!4']});
| [reply] [d/l] [select] |
That is, if you're willing to pay the performance penalty for no_chdir, and in this case, it seemed unwarranted, since the workaround was so easy.
-- Randal L. Schwartz, Perl hacker
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.
| [reply] |