my $stop_the_insanity = 0; sub wanted { $File::Find::prune = $stop_the_insanity; return if $stop_the_insanity; ... # some condition that sets $stop_the_insanity ... }