you are looking for
assertions, unfortunatelly they only work on the unstable versions of perl.
assertions::compat is also available but it requires you to test constants explicitelly as ...
dbg and expensive_test();
Another similar module is ctflags (that stands for "compile time flags"), it is overly complex with too many options... but for what you need:
In some place, at the beggining of your script, include this code to set flags from an environment variable:
use ctflags::parse ns => "myapp:debug", env=>'MYAPPDEBUG';
then in every module where you want to conditionally execute something add:
use ctflags prefix=>'dbg_', 'myapp:debug:*';
dbg_a and print "a flag is on\n";
dbg_b and print "b flag is on\n";
dbg_c and print "c flag is on\n";
Finally, if you call your script as
$ MYAPPDEBUG=ac perl myapp.pl
it will output
a flag is on
c flag is on