For a different approach I suggest you consider
Smart-Comments, which uses a source filter but does all the work for you. You don't even have to modify your code, you can turn smart comments on and even control the verbosity level at runtime via e.g.
perl -MSmart::Comments myscript.pl
perl -MSmart::Comments="####" myscript.pl
See the documentation and
Re^2: debug statements for details.