use strict; use constant DEBUG => 1; # many lines of code here &assert($val, $var1, $var2) if DEBUG; # many lines of code here sub assert() { my $test = shift; my (@vars) = @_; # test $test for condition # if test condition is true # do something with @vars (usually dump them) print "would you like to abort: "; my $ans = ; exit if $ans =~ m/y/i; }