in reply to Re: Quotable Quotes
in thread Quotable Quotes

It appears to me that everyone is missing the point. Perhaps I was too verbose in my question, so let me be terse this time.

Ignore all the echo example, that was just to illustrate a point. My real question is just this one:

print STDERR `"My Echo.pl"`; print STDERR `"My Echo (v1).pl"`;
The first line works. The second doesn't. Why?

The behavior is consistent. Any file name with a parenthesis does not work. Others seem to work just fine.

Yes I know, I can rewrite things (eg. `perl "My Echo (v1).pl"`). My question still is: Why?

Replies are listed 'Best First'.
Re^3: Quotable Quotes
by goibhniu (Hermit) on Sep 07, 2007 at 20:29 UTC

    I think I've reproduced your problem in my environment. Triple double-quotes doesn't solve it:

    C:\chas_sandbox>copy con "My Echo.pl" print "hello, world\n"; ^Z 1 file(s) copied. C:\chas_sandbox>copy con "My Echo (v1).pl" print "hello, world\n"; ^Z 1 file(s) copied. C:\chas_sandbox>"My Echo (v1).pl" hello, world C:\chas_sandbox>"My Echo.pl" hello, world C:\chas_sandbox>perl -e "print STDERR `"My Echo.pl"`;" Can't find string terminator "`" anywhere before EOF at -e line 1. C:\chas_sandbox>perl -e "print STDERR `"""My Echo.pl"""`;" hello, world C:\chas_sandbox>perl -e "print STDERR `"My Echo (v1).pl"`;" Can't find string terminator "`" anywhere before EOF at -e line 1. C:\chas_sandbox>perl -e "print STDERR `"""My Echo (v1).pl"""`;" 'My' is not recognized as an internal or external command, operable program or batch file.

    It's obviously getting to the cmd shell, since the not recognized as an internal or external command is from cmd.

    per Sandy's message, below, it's definitely the ()'s that are messing you up. And it's cmd that doesn't like them, not Perl.

    I know you're still asking "why?" but here's another tack for a work-around:

    C:\chas_sandbox>dir /x "My Echo (v1).pl" Volume in drive C has no label. Volume Serial Number is D425-A27D Directory of C:\chas_sandbox 09/07/2007 04:22 PM 25 MYECHO~2.PL My Echo (v1).pl 1 File(s) 25 bytes 0 Dir(s) 28,821,581,824 bytes free C:\chas_sandbox>perl -e "print STDERR `MYECHO~2.PL`;" hello, world C:\chas_sandbox>

    I've used dir /x to get the short name and called the script using the shortname between the backticks.


    I humbly seek wisdom.

      Here's lots of inconsistent behavior, all of which (I think) can be blamed on cmd.exe

      C:\chas_sandbox>"My Echo (v1).pl" hello, world C:\chas_sandbox>cmd /c "My Echo (v1).pl" 'My' is not recognized as an internal or external command, operable program or batch file. C:\chas_sandbox>cmd /c " "My Echo (v1).pl"" hello, world C:\chas_sandbox>cmd /c ""My Echo (v1).pl"" hello, world C:\chas_sandbox>perl -e "print STDERR ` """My Echo (v1).pl"""`;" hello, world C:\chas_sandbox>perl -e "print STDERR `""" """My Echo (v1).pl""""""`;" '" "My' is not recognized as an internal or external command, operable program or batch file. C:\chas_sandbox>


      I humbly seek wisdom.
Re^3: Quotable Quotes
by narainhere (Monk) on Sep 07, 2007 at 19:16 UTC
    Maybe the '(' symbol gives some special meaning .I'm nt sure!!!

    The world is so big for any individual to conquer