Maybe your echo is different.

Ah, right, that seems to be the issue — apparently, my echo is swallowing the quotes...  With $^X, perl is being passed the arguments as expected:

c:\>perl t.pl -p blastn -d value of $hu_seq value of $hd_seq -i value of $contig -o value of $alignment

So far so good.  OTOH, the reason I had tried this again at all was that I dimly remembered having had "issues" with the multi-argument form of system() recently (on Windows):  I had to pass a double-quoted value (a filename with spaces) through to another script (outside of my control), which itself was then calling system(). Due to the way the script was written, one level of quoting was being removed, which is why the argument itself needed to contain double quotes around the filename.

I had tried something like this

my $outfile = '\"c:\Documents and Settings\foo\my file\"'; my @command = ( $^X, '-leprint for @ARGV', '--', '-o', $outfile ); 0 == system @command or die "system @command failed: $?";

expecting that $outfile would automatically get an outer pair of double quotes added around the specified value. However, it didn't, producing

c:\>perl t.pl -o "c:\Documents and Settings\foo\my file"

while the corresponding one-argument form works fine

my $outfile = '\"c:\Documents and Settings\foo\my file\"'; my $command = qq($^X -le"print for \@ARGV" -- -o "$outfile"); 0 == system $command or die "system $command failed: $?"; __END__ -o "c:\Documents and Settings\foo\my file"

Seems kind of inconsequent to me that with the multi-argument form, you still have to fiddle with the quoting yourself, i.e. add extra outer double quotes like this

my $outfile = '"\"c:\Documents and Settings\foo\my file\""';

to get the correct behavior. Why isn't this being done by Perl, when other values are apparently being quoted properly?


In reply to Re^6: quoting issue with system command (Win32) by almut
in thread quoting issue with system command by lomSpace

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.