“Badly placed ()'s” error when running loc command

1k views Asked by At

I keep getting errors like Badly placed ()'s and I don't understand why.

The following row is giving me this printout

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

I'm running a command like this

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

It has obviously something to do with my ${"${file_type}_flag"} but I don't know how to debug this. How can I print out the command that it tries to execute?

Don't mention that ${old_file} or ${new_file} don't exist. They are on the form nameOfFile.h or nameOfFile.cpp etc.

1

There are 1 answers

0
ikegami On BEST ANSWER

It has obviously something to do with my ${"${file_type}_flag"} but I don't know how to debug this. How can I print out the command that it tries to execute?

With print, of course.

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

warn will send it to STDERR instead.

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