gpt4 book ai didi

perl - 运行 Perl 调试器两次

转载 作者:行者123 更新时间:2023-12-03 02:02:00 27 4
gpt4 key购买 nike

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

use warnings;
use strict;

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

progB.pl:

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

然后我运行progA.pl,如下所示:

$ perl -d progA.pl

这效果不太好。在我的系统(Ubuntu 14.04 和 Perl 版本 5.18)上,我从调试器中收到一些错误。例如:

### 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.

它还尝试打开一个新的终端窗口,标题为Dauther Perl debugger,但新终端仅显示错误sh: 1: 3:错误的文件描述符

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

最佳答案

使用“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`;

关于perl - 运行 Perl 调试器两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25520556/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com