Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
No such thing as a small change
 
PerlMonks  

command line error

by hsfrey (Beadle)
on Apr 12, 2012 at 06:13 UTC ( #964706=perlquestion: print w/ replies, xml ) Need Help??
hsfrey has asked for the wisdom of the Perl Monks concerning the following question:

I can't get the perl command line to work, using Active Perl on windows XP.

If I type: perl -e 'print "XXX";' I get the error message: Can't find string terminator "'" anywhere before EOF at -e line 1. (That's a single quote between 2 double quotes.)

I get the same error if I type: perl -e 'print $a;'

I get no error if I type: perl -e '$a=3;', but of course no output either.

Does anyone have any idea what the problem is or how I could debug the problem?

Comment on command line error
Re: command line error
by davido (Archbishop) on Apr 12, 2012 at 06:21 UTC

    Try this:

    perl -e "print qq/XXX/;"

    The msdos shell (or whatever they call it nowadays) wants you to use "....". Of course that leads to the problem that you can't use double quotes within the code, so you use an alternative such as qq// instead. Alternate quote-like operators such as qq// are discussed in perlop. When your actual code has embedded double quotes the command shell parses it wrong.

    There is some information in this document, if you search its content for the word "quote"

    http://technet.microsoft.com/en-us/library/cc723564.aspx

    So for *nix environments, wrap your code in '...', and in Win/dos environments, wrap it in "...".


    Dave

      Thanks Dave, That did it!

      I just escaped the inner double quotes, and it all worked fine.

      It's surprising that the Active Perl documentation says nothing about this problem.

      Well, maybe I shouldn't be surprised - their documentation is a total kloodge.

        To be fair, this has more to do with the MSDOS prompt than it does with Active Perl.
Re: command line error ( Can't find string terminator "'" anywhere before EOF at -e line 1. )
by Anonymous Monk on Apr 12, 2012 at 06:54 UTC
Re: command line error
by rovf (Priest) on Apr 12, 2012 at 10:04 UTC
    This is a Windoze question, not a Perl question: Unless you are using one of the Cygwin shells (bash, zsh, ...), single quotes are not valid delimiters in the Windoze Command Shell.


    -- 
    Ronald Fischer <ynnor@mm.st>

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://964706]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (12)
As of 2014-04-18 19:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (471 votes), past polls