use constant DEBUG => 1; ... ... my $debugsub = DEBUG ? { warn @_ } : {}; #need to fix stack trace... ... ... &$debugsub(foobar);