Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.

In reply to Re: Note on usage of ours variables and a question -- ENV by Discipulus
in thread Note on usage of ours variables and a question by likbez

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-03-28 14:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found