if ($debug) { my $sub = \&some_function; my $wrapsub = sub { __x(@_); $sub->(@_) }; *some_function = $wrapsub; }