Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.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

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
Linux 在调试模式下运行Perl脚本_Linux_Perl - Fatal编程技术网

Linux 在调试模式下运行Perl脚本

Linux 在调试模式下运行Perl脚本,linux,perl,Linux,Perl,如何在调试模式下运行Perl脚本,如bash-x for shell脚本 我尝试了-w参数,如下例所示: #!/usr/bin/perl -w 但是没有成功 use strict; use warnings; use diagnostics; 在我看来,这已经足够了 如果要使用调试器,请签出: 您可以将内置命令行调试器用作: perl -d yourcode.pl 另见: perl-Dt有点像bash-x,但是您需要专门编译perl以允许这种跟踪 但对于任何perl,都可以使用调试器运行脚

如何在调试模式下运行Perl脚本,如bash-x for shell脚本

我尝试了-w参数,如下例所示:

#!/usr/bin/perl -w
但是没有成功

use strict;
use warnings;
use diagnostics;
在我看来,这已经足够了

如果要使用调试器,请签出:

您可以将内置命令行调试器用作:

perl -d yourcode.pl
另见:

perl-Dt有点像bash-x,但是您需要专门编译perl以允许这种跟踪

但对于任何perl,都可以使用调试器运行脚本:

perl -d yourscriptname yourscriptargs
有关Perl脚本的bash-x样式跟踪,请参阅以获取初学者信息。

有关Perl脚本的bash-x样式跟踪,请查看Devel::DumpTrace。例如:

demo.pl:

      #!/usr/bin/perl
      # demo.pl: a demonstration of Devel::DumpTrace
      $a = 1;
      $b = 3;
      $c = 2 * $a + 7 * $b;
      @d = ($a, $b, $c + $b);
程序输出:

      $ perl -d:DumpTrace demo.pl
      >>>>> demo.pl:3:        $a:1 = 1;
      >>>>> demo.pl:4:        $b:3 = 3;
      >>>>> demo.pl:5:        $c:23 = 2 * $a:1 + 7 * $b:3;
      >>>>> demo.pl:6:        @d:(1,3,26) = ($a:1, $b:3, $c:23 + $b:3);

你说没成功是什么意思?请说明您如何尝试运行脚本以及错误是什么。欢迎使用堆栈溢出。请尽快阅读这一页。-w可以工作,但它不运行调试,而是在Perl编译脚本时添加警告。有关如何运行和使用Perl调试器的信息,请参阅。请注意,如果有一个问题说如果不显示代码、实际结果和预期结果,它就无法工作,那么这个问题就不是真正可以回答的-这样的问题通常以“离题”结尾。-w在perl中激活警告。有关调试的详细信息,请参阅。的可能重复项