Perl命令未作为脚本的一部分执行

时间:2015-08-24 22:24:26

标签: perl debugging hash command scripting-language

我有一个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.plvrt_scalability.p'是一个单独的脚本,可以从命令行工作,但是当我尝试使用此wrapper.pl执行它时,它失败了。我该如何调试这种代码?

此外,当我独立于cmd运行它们时,此代码的wrapper.pl部分中调用的命令都可以正常工作。我能做错什么?

在这里执行脚本:

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);
        }
    }  

1 个答案:

答案 0 :(得分:1)

您正在填充$conf->{script_list}但稍后使用$conf->{exec_list}

如何调试?我经常使用https://metacpan.org/pod/Data::Dumperhttps://metacpan.org/pod/Log::Log4perl::Tiny(无耻插件)的组合,并在代码中添加调试语句,以确保每一步都发生了什么。

在这种情况下,例如,我会在输入$conf时添加整个ExecScripts变量的打印输出。