Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

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


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 12: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
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found