my $found_any = 0; ... sub search_all { unlink, $found_any++ if /.../; } # (repeat for search_none) print "No files found!\n" unless $found_any;