Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
运行Perl调试器两次_Perl - Fatal编程技术网

运行Perl调试器两次

运行Perl调试器两次,perl,Perl,我有一个例子,我调用Perl调试器两次。例如,progA.pl: use warnings; use strict; system("perl -d progB.pl"); use warnings; use strict; $DB::single=1; print "Hello\n"; 和progB.pl: use warnings; use strict; system("perl -d progB.pl"); use warnings; use strict; $DB::sing

我有一个例子,我调用Perl调试器两次。例如,
progA.pl

use warnings;
use strict;

system("perl -d progB.pl");
use warnings;
use strict;
$DB::single=1;
print "Hello\n";
progB.pl

use warnings;
use strict;

system("perl -d progB.pl");
use warnings;
use strict;
$DB::single=1;
print "Hello\n";
然后我运行
progA.pl
如下:

$ perl -d progA.pl
这不太管用。在我的系统(Ubuntu14.04和Perl版本5.18)上,我从调试器中得到一些错误。例如:

###分叉,但不知道如何创建新的TTY由于两个调试器争夺同一个TTY,因此输入受到严重影响 纠缠

我知道如何在xterms中将输出切换到其他窗口, 仅限OS/2控制台和Mac OS X Terminal.app。对于手动开关, 将创建的TTY的名称放在$DB::fork\u TTY中,或定义一个 函数DB::get\u fork\u TTY()返回此值

在类UNIX系统上,可以获得给定系统的TTY名称 通过键入tty打开窗口,并通过sleep断开shell与tty的连接 一百万

它还尝试打开一个新的终端窗口,标题为“Dauther Perl debugger”,但新终端只显示错误
sh:1:3:Bad file descriptor


如何避免这些问题?我只希望调试器能正常工作

使用“do”而不是“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`;

我不确定这是否是你想要的,因为我不明白你想做什么

但如果一开始就使用不同的调试器,那么事情可能会起作用:

$ trepan.pl progA.pl 
-- main::(progA.pl:4 @0x21282c8)
system("perl -d progB.pl");
(trepanpl): s
-- main::(progB.pl:3 @0x7042a8)
$DB::single=1;
(trepanpl): s
-- main::(progB.pl:4 @0x878be8)
print "Hello\n";
(trepanpl): s
Hello
Debugged program terminated.  Use 'q' to quit or 'R' to restart.
(trepanpl): quit
trepan.pl: That's all, folks...
Debugged program terminated.  Use 'q' to quit or 'R' to restart 
(trepanpl) quit
trepan.pl: That's all, folks...
“程序终止”消息后的
(trepanpl)
提示有点奇怪。但这意味着progB.pl已经完成。在退出之后,正如我前面所做的,如果在system()命令之后有另一个Perl语句,那么调试器将显示该语句,而不是给出第二条“finished”消息

Trepan的另一个特性是,您可以使用其。以下是一个例子:

trepan.pl progA.pl 
-- main::(progA.pl:4 @0x10612c8)
system("perl -d progB.pl");
set auto eval is on.
(trepanpl): debug system("perl -d progB.pl")
-- main::((eval 1437)[/usr/local/share/perl/5.18.2/Devel/Trepan/DB/../../../Devel/Trepan/DB/Eval.pm:129] remapped /tmp/HSXy.pl:6 @0x51f13e0)
system("perl -d progB.pl")
((trepanpl)): s
-- main::(progB.pl:3 @0x9382a8)
$DB::single=1;
(trepanpl): s
-- main::(progB.pl:4 @0xaacbe8)
print "Hello\n";
(trepanpl): s
Hello
Debugged program terminated.  Use 'q' to quit or 'R' to restart.
(trepanpl): quit
trepan.pl: That's all, folks...
$DB::D[0] = 0
Leaving nested debug level 1
-- main::(progA.pl:4 @0x10612c8)
system("perl -d progB.pl");
(trepanpl): 

为什么要使用system()在调试模式下启动Perl?我不是在linux机器上,所以无法进行测试,但类似的东西应该可以工作:
system('xterm-e Perl-d progB.pl')