This is most weird. In your case, with the hard-coded perl, it works as expected (5.8.3 here). And the following fails, as supported by your assertion:
> perl -e"@cmd = ('perl ', '-le print for @ARGV', 'foo bar'); system @
+cmd"
Der Befehl ""perl "" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
But the following does not fail:
>perl -le "print $^X;@cmd = ($^X.' ', '-le print for @ARGV', 'foo bar'
+); system @cmd"
C:\Programme\Perl\bin\perl.exe
foo bar
So my guess is that $cmd[0] is inspected for whitespace or quotes, and if it contains either, an intermediate shell is invoked. Which is just a horrible kludge, especially when most programs live (under some languages) under C:\Program Files\, which already contains whitespace. And there, quoting becomes necessary:
>perl -le "@cmd = (chr(34).$^X.' '.chr(34).' -le print+1 for @ARGV', '
+foo bar'); system @cmd"
1
It fails (properly) when the first parameter does not start with quotes, again:
>perl -le "@cmd = ($^X.' -le print+1 for @ARGV', 'foo bar'); system @c
+md"
Der Befehl ""C:\Programme\Perl\bin\perl.exe -le print+1 for @ARGV"" is
+t entweder falsch geschrieben oder
konnte nicht gefunden werden.
|