Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am having trouble writing commands for the following commands and running into the following problem and error.Can anyone advise?
1.$cmd = [ qw(p4 submit -d $options{des} -f submitunchanged -i) ]; run3($cmd, \$stdin, \$stdout, \$stderr); print "\n$stderr\n"; Problem:-Not deciphering $options{des} $cmd = [ qw(p4 tag -l TEST_$options{r}_$dat $options{v}) ]; run3($cmd, \$stdin, \$stdout, \$stderr); print "\n$stderr\n"; Error:-$options{v} - no such file(s). The following commands work using system though system qq(p4 tag -l TEST_"$options{r}"_$date $options{v});

Replies are listed 'Best First'.
Re: problem and error writing a command
by wind (Priest) on Mar 11, 2011 at 07:24 UTC

    qw() doesn't interpolate, therefore $options{des} will be treated as a literal string.

    Use the following if you really want each element as a list instead of a single string like if you used qq{}.

    $cmd = [ qw(p4 submit -d), $options{des}, qw(-f submitunchanged -i) +];
      I figured out for the step 1,but for step2 I am having trouble figuring out...getting the below syntax error...Please advise
      $cmd = [ qw(p4 tag -l ), TEST_$options{r}_$date, $options{v} ]; run3($cmd, \$stdin, \$stdout, \$stderr); print "\n$stderr\n";
      syntax error at perl.pl line 197, near "$options{r" Execution of perl.pl aborted due to compilation errors.
        $cmd = [ qw(p4 tag -l), "TEST_$options{r}_$dat", $options{v} ];
Re: problem and error writing a command
by ikegami (Patriarch) on Mar 11, 2011 at 07:25 UTC
    qw() is not qq(). It doesn't interpolate.