0

我有两个这样的 Perl 文件。使用 perl5db.pl 我试图在 file2.pl 的第 7 行设置一个断点,但遗憾的是它不允许我这样做。我寻找答案,发现我可以使用模块,但 file2.pl 没有使用模块。我能做些什么?

#file.pl is
#!/usr/bin/perl

use strict;
use warnings;
require "file2.pl";

#  This file is a test file to run the debugger on.

hello();
my $var = 1;
my $var2 = 2;
makeEqual();
sub main {
  if($var == $var2){
    print "they are equal\n";
  }
  else {
    print "they are not equal\n";
    makeEqual();
  }
  my $value =2;
  print "the value is $value\n";

}

sub makeEqual {
  $var = $var2;
  my $str = "  this is crazy";
  $str =~ s/\s+/ /g;
  print "$str is done \n";
}
main();

#file2.pl is

#!/usr/bin/perl

use strict;
use warnings;

sub hello {
  print "I am in hello";
}
1;
4

1 回答 1

1

就在 init 之后,您的调试器设置了一个断点以在编译您的函数后停止,当调试器在该点停止时,您将能够看到该文件的函数file2.pl的 return 语句(指令)。1;hello

执行调试器:

perl -d file.pl

hello编译函数时停止:

DB<1> b compile hello

继续:

DB<2> c

现在函数hello存在,因此在其中设置断点并继续:

DB<2> b hello
DB<3> c

现在你在那里:

main::hello(file2.pl:7):      print "I am in hello";
于 2013-07-26T07:06:43.740 回答