我有一个Perl脚本wrapper.pl,其中有一段代码,如下所示:
if (-e "$run_dir/fd3d/VrtMsgBus.txt") {
print "VRTMSGBUS: non scalablity mode VrtMsgBus.txt exists\n";
$conf->{'script_list'}{'vrt_scalability'} = {
'cmd' => "perl $script_dir/hevc_enc/pak_rtl/vrt_scalability.pl $run_dir $hevc_fd3d_dir $script_dir",
'dumpdir' => $dumpdir,
'units' => [qw(hwm hle vne hvd hsse hit hpo hfq hft hpr hrs hlc hmc hpp hed vnc htq hsao hmx hlf)],
'requires' => [qw(vrtmsgbus mv_vrtmsgbus mv_vrtmsgbus_org mv_vrtmsgbus_no_scalability)],
};
}
else {
print "VRTMSGBUS: scalablity mode, VrtMsgBus.txt doesnt exist\n";
$conf->{'script_list'}{'vrt_scalability_2'} = {
'cmd' => "perl $script_dir/hevc_enc/pak_rtl/vrt_scalability.pl $run_dir $hevc_fd3d_dir $script_dir",
'dumpdir' => $dumpdir,
'units' => [qw(hwm hle vne hvd hsse hit hpo hfq hft hpr hrs hlc hmc hpp hed vnc htq hsao hmx hlf)],
};
} 我正在尝试以代码中所示的方式针对不同的条件执行特定的脚本vrt_scalability.pl。vrt_scalability.p‘是一个单独的脚本,可以从命令行运行,但当我尝试使用此wrapper.pl执行它时,它会失败。如何调试这类代码?
此外,当我独立于wrapper.pl运行在此代码的cmd部分中调用的命令时,它们都可以正常工作。我能做错什么呢?
在此处执行脚本:
sub ExecScripts {
foreach my $exec_script_name (keys %{$conf->{'exec_list'}})
{
$conf->{'exec_list'}{$exec_script_name}{'script_was_executed'} = 0;
}
foreach my $exec_script_name (keys %{$conf->{'exec_list'}})
{
my $dependency_script = $conf->{'exec_list'}{$exec_script_name};
if (exists $dependency_script->{'requires'})
{
foreach my $parent_script (@{$dependency_script->{'requires'}})
{
ExecDependencyScripts($conf, $parent_script);
}
} 发布于 2015-08-25 20:02:10
您将填充$conf->{script_list},但稍后将使用$conf->{exec_list}。
如何调试?我经常使用https://metacpan.org/pod/Data::Dumper和https://metacpan.org/pod/Log::Log4perl::Tiny (不知羞耻的插件)的组合,并在代码中添加调试语句,以确保每个步骤都发生了什么。
例如,在本例中,我将在输入ExecScripts时添加整个$conf变量的打印输出。
https://stackoverflow.com/questions/32192730
复制相似问题