Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: perl -d at runtime?

by ccarden (Monk)
on Dec 19, 2003 at 19:09 UTC ( [id://315875]=note: print w/replies, xml ) Need Help??


in reply to perl -d at runtime?

You can definitely do this in your script:

#!/usr/bin/perl -d

... loads up the debugger correctly.

So what if you had two versions of your script ... one with -d in the shebang line, and one without? Call the -d version when your condition requires it. Sloppy but it works.

Replies are listed 'Best First'.
Re: Re: perl -d at runtime?
by QM (Parson) on Dec 20, 2003 at 01:15 UTC
    Reworking davido's idea above:
    if ( ( do_I_want_debug ) and ( not defined( $DB::VERSION ) ) # already in debug? { exec('perl -d $0 @ARGV') or die $!; }
    I can't remember the variable to check if the debugger is running. $DEBUGGING used to work, but not here on ActiveState 5.8.0.

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

      I ended up stripping the -d arg and using exec.
      #!/usr/bin/perl -w BEGIN { # handle -d by itself to start the debugger @ARGV = grep { $_ eq '-d' ? !($opt_d=1) : 1 } @ARGV; exec('/usr/bin/perl','-dS',$0,@ARGV) if $opt_d; } ...
      Note that this doesn't do clustering like smarter switch process.

      Also, I don't know if I need that -S but it's not hurting yet.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-25 16:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found