我有两个像这样的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;
答案 0 :(得分:1)
初始化后,调试器在编译file2.pl
函数后设置断点以停止,当调试器在此时停止时,返回语句(指令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";