use constant DEBUG => $ENV{DEBUG_LEVEL} // 0; # Handle undef gracefully ... sub helpful { my $int = shift; debug(1, "called with: ", $int) if DEBUG > 0; # <-- Add this ## do stuff here ... my $val = $int * $int; debug(3, "output: ", $val) if DEBUG > 0; # <-- Add this print "$int becomes: $val \n"; } ...