b4swine has asked for the wisdom of the Perl Monks concerning the following question:
producesprint STDERR `"echo hello"`;
But, when run at a DOS prompt, the command:hello
producesC:\>"echo hello"
It appears that in this case, perl did not send the quotes to DOS.'"echo hello"' is not recognized as an internal or external command, o +perable program or batch file.
I create a copy of the same file with the name My Echo (v1).pl.
Now I run the following perl program:
And the result isprint STDERR `"My Echo.pl"`; print STDERR `"My Echo (v1).pl"`;
echo 'My' is not recognized as an internal or external command, operable pr +ogram or batch file.
Update: I know that print STDERR `My\\ Echo (v1).pl`; will work, but for my own reasons, I want to use quotes (I don't want to parse the string an find all spaces etc).
Update: The explanation is almost surely given in the answer by Sandy. It is clear that this has nothing to do with perl and is just another weirdness of MSDOS (JAWMS). The cmd.exe drops the quotes under some circumstances. Actually the case in point doesn't match any of the documented circumstances mentioned in the documentation of cmd.exe, but then that is Microsoft. The final proof (as shown by goibhniu is the following DOS output (no perl involved):
C:\>cmd/c "My Echo.pl" echo C:\>cmd/c "My Echo (v1).pl" 'My' is not recognized as an internal or external command, operable program or batch file.
Updated Solution: Just put a space after the last quote, and DOS then does not strip the quotes in its bizzare inconsistent way. Eg: `"dos command with spaces and (parens).pl" ` I wonder if this bug is mentioned at Microsoft.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Quotable Quotes
by cdarke (Prior) on Sep 07, 2007 at 11:53 UTC | |
|
Re: Quotable Quotes
by goibhniu (Hermit) on Sep 07, 2007 at 12:34 UTC | |
by b4swine (Pilgrim) on Sep 07, 2007 at 16:01 UTC | |
by goibhniu (Hermit) on Sep 07, 2007 at 20:29 UTC | |
by goibhniu (Hermit) on Sep 07, 2007 at 20:58 UTC | |
by narainhere (Monk) on Sep 07, 2007 at 19:16 UTC | |
|
Re: Quotable Quotes
by m0ve (Scribe) on Sep 07, 2007 at 08:06 UTC | |
|
Re: Quotable Quotes
by Sandy (Curate) on Sep 07, 2007 at 20:28 UTC | |
|
Re: Quotable Quotes
by erroneousBollock (Curate) on Sep 07, 2007 at 08:10 UTC | |
by b4swine (Pilgrim) on Sep 07, 2007 at 09:21 UTC | |
by Anonymous Monk on Sep 07, 2007 at 11:43 UTC | |
by Anonymous Monk on Sep 07, 2007 at 11:48 UTC | |
by m0ve (Scribe) on Sep 07, 2007 at 11:13 UTC |