Dear kind perl guru:

I am aware of the differences between qx// and system(), but here is my
problem...

$s = "\`backquoted'string\`"

print $s,"\n";
#    => `backquoted'string`

system ("echo", $s);
#    => `backquoted'string`

system "echo $s";
#    => sh: command substitution: line 1: unexpected EOF while looking for
#    => matching `''
#    => sh: command substitution: line 2: syntax error: unexpected end of file

print `echo $s`;
#    => sh: command substitution: line 1: unexpected EOF while looking for
#    => matching `''
#    => sh: command substitution: line 2: syntax error: unexpected end of file

As you see, system(@) succeeds because the arguments are passed as-is.
system($) and qx// fail because sh is invoked to further parse the command
line.  What method can you suggest that will allow me to capture the STDOUT of
an external command, while being able to robustly handle aguments containing
[\'"`].

I have considered the following method which appears to work, but am unsure if
it will handle all cases, with respect to how sh interprets backslashes and
its wide assortment of other special characters.

$s = quotemeta "\`backquoted'string\` & \"killer bees'\"";
print `echo $s`
#    => `backquoted'string` & "killer bees'"

Thanks for any help,

Aaron VonderHaar
([EMAIL PROTECTED])

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to