in reply to redirect function to /dev/null

{ # Temporarily undefine STDOUT. local *STDOUT; func(); }
as in
sub func { print("in func\n"); } print("pre func\n"); { # Temporarily undefine STDOUT. local *STDOUT; func(); } print("post func\n");

If func checks the return value of print in the above, it will notice that print failed. If you really wanted to print to /dev/nul (or to another file) and avoid that (rare) problem, you'd use

{ # Temporarily redirect STDOUT. open(local *STDOUT, '>', '/dev/nul'); func(); }

You can do the same with STDERR. You might also want to look at $SIG{__WARN__}.