运行loc命令时出现“错误放置()'”错误

时间:2015-06-08 14:46:33

标签: perl

我一直收到像Badly placed ()'s这样的错误,我不明白为什么。

以下一行给我打印输出

${tmp} = `${loc} ${"${type}_flag"} ${old_view_path}/${old_file} > ${tmpdir}/old_file`;

我正在运行这样的命令

system("${ct} startview ${new_view}");
system("${ct} startview ${old_view}");
${new_view_path} = "/view/${new_view}";
${old_view_path} = "/view/${old_view}";
${loc} = "/proj/uz/util/bin/loc";

@{file_types} = ();
${file_type} = "Erlang";
push @{file_types},${file_type};
@{"${file_type}_ext"} = split /,/,"erl,hrl";
${"${file_type}_flag"} = "-erl";

${file_type} = "IDL";
push @{file_types},${file_type};
@{"${file_type}_ext"} = split /,/,"idl";
${"${file_type}_flag"} = "-erl";

${file_type} = "C";
push @{file_types},${file_type};
@{"${file_type}_ext"} = split /,/,"c,h";
${"${file_type}_flag"} = "-c";

${file_type} = "C++";
push @{file_types},${file_type};
@{"${file_type}_ext"} = split /,/,"cc, cpp, hh, hpp";
${"${file_type}_flag"} = "-c++";

${file_type} = "Assembler";
push @{file_types},${file_type};
@{"${file_type}_ext"} = split /,/,"s";
${"${file_type}_flag"} = "-c";

${file_type} = "Java";
push @{file_types},${file_type};
@{"${file_type}_ext"} = split /,/,"java,classes";
${"${file_type}_flag"} = "-c++";

foreach ${type} (@{file_types}){
     //The bellow give me sometimes error like badly placed ()'s
     ${tmp} = `${loc} ${"${type}_flag"} ${old_view_path}/${old_file} > ${tmpdir}/old_file`;
}

这显然与我的${"${file_type}_flag"}有关,但我不知道如何调试它。如何打印出它试图执行的命令?

请勿提及${old_file}${new_file}不存在。它们位于nameOfFile.hnameOfFile.cpp等表单上。

1 个答案:

答案 0 :(得分:0)

  

这显然与我的${"${file_type}_flag"}有关,但我不知道如何调试它。如何打印出它试图执行的命令?

当然是print

print(qq{${loc} ${"${type}_flag"} ${old_view_path}/${old_file} > ${tmpdir}/old_file\n});

warn会将其发送给STDERR。

warn(qq{${loc} ${"${type}_flag"} ${old_view_path}/${old_file} > ${tmpdir}/old_file\n});