Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Perl debugger twice

Tags:

perl

I have a case where I invoke the Perl debugger twice. For example, progA.pl:

use warnings;
use strict;

system("perl -d progB.pl");

and progB.pl:

use warnings;
use strict;
$DB::single=1;
print "Hello\n";

Then I run progA.pl like:

$ perl -d progA.pl

This does not work very well. On my system (Ubuntu 14.04, and Perl version 5.18), I get some errors from the debugger. For example:

### Forked, but do not know how to create a new TTY. ######### Since two debuggers fight for the same TTY, input is severely

entangled.

I know how to switch the output to a different window in xterms, OS/2 consoles, and Mac OS X Terminal.app only. For a manual switch, put the name of the created TTY in $DB::fork_TTY, or define a function DB::get_fork_TTY() returning this.

On UNIX-like systems one can get the name of a TTY for the given window by typing tty, and disconnect the shell from TTY by sleep 1000000.

It also tries to open a new terminal window, with title Dauther Perl debugger but the new terminal only show the error sh: 1: 3: Bad file descriptor.

How can these problems be avoided? I just want the debugger to work as normal.

like image 453
Håkon Hægland Avatar asked Mar 14 '26 19:03

Håkon Hægland


1 Answers

Use 'do' instead of 'system'

perl -d progA.pl
# will stop after your $DB::single = 1 
# line in progB.pl

perldoc -f do

    do EXPR Uses the value of EXPR as a filename and executes the contents
            of the file as a Perl script.

                   do 'stat.pl';

               is just like

                   eval `cat stat.pl`;
like image 162
xxfelixxx Avatar answered Mar 17 '26 09:03

xxfelixxx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!