http://qs321.pair.com?node_id=11108950


in reply to Note on usage of ours variables and a question

Hello likbez,

you already received many good options and approaches, but your:

> BTW does Perl have a system variable "debug" that is global and does not need qualification with the package name?

prompts me for another answer: yes! you have %ENV at your disposal and you can create your own varaiable like DEBUG_TEMP that is uber global

#cat Example.pm package Example; use strict; use warnings; sub my_test{ print "output from sub\n"; print "package ",__PACKAGE__," spot debug!!\n" if $ENV{DEBUG_T +EMP}; } 1; #cat test-env.pl use strict; use warnings; use lib '.'; use Example; Example::my_test(); # test without the var $ENV{DEBUG_TEMP} = 1; Example::my_test(); # test with the var #perl test-env.pl output from sub # output before var setting output from sub # two lines after var setting package Example spot debug!! # when the program exits, DEBUG_TEMP disappears #perl -I . -MExample -e "Example::my_test()" output from sub

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.