Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Note on usage of ours variables and a question -- ENV

by Discipulus (Abbot)
on Nov 20, 2019 at 20:18 UTC ( #11108950=note: print w/replies, xml ) Need Help??

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 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 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 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


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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11108950]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2021-10-25 14:26 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (89 votes). Check out past polls.