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

Re^4: Using the Perl Debugger (-d)

by bart (Canon)
on Jan 26, 2007 at 06:59 UTC ( [id://596697]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re^3: Using the Perl Debugger (-d)
in thread Using the Perl Debugger (-d)

I'm sure it must be feasable to set the value for the constant based on a command line switch. I'm not sure if one can just plug in use a module like Getopt::Std or Getopt::Long for this — they probably work at runtime, and might interfere with your own use of command line switches. Hence the handcrafted code, in the example:
{ my $debug; BEGIN { if(grep { $_ eq '-d' } @ARGV) { # look for switch $debug = 1; @ARGV = grep { $_ ne '-d' } @ARGV; # remove switch } } use constant DEBUG => $debug; } print "Debug is on" if DEBUG;

Does anybody else get a "Useless use of a constant in void context" warning for the print line if DEBUG is off, or is it my old Perl version (5.6.1)? -MO=Deparse tells me it got replaced by the statement '???';, which might explain it. It's still silly.

Replies are listed 'Best First'.
Re^5: Using the Perl Debugger (-d)
by BrowserUk (Patriarch) on Jan 26, 2007 at 07:09 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://596697]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.