Perl 不同文件中函数中的断点
我有两个像这样的Perl文件。使用perl5db.pl,我试图在file2.pl的第7行设置一个断点,但遗憾的是,它不允许我这样做。我寻找答案,发现我可以使用模块,但file2.pl没有使用模块。我能做什么Perl 不同文件中函数中的断点,perl,debugging,Perl,Debugging,我有两个像这样的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
#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
函数后将断点设置为stop,当调试器在该点停止时,返回语句(指令1;
)将能够看到该文件的hello
函数
执行调试器:
perl -d file.pl
编译函数hello
时停止:
DB<1> b compile hello
现在你到了:
main::hello(file2.pl:7): print "I am in hello";
我可以用use替换require吗?我想这样我就不必每次编译了,但是,我不明白module,file2.pl的模块是什么…它和前一个在同一个目录中…谢谢
DB<2> c
DB<2> b hello
DB<3> c
main::hello(file2.pl:7): print "I am in hello";