Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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?

Replies are listed 'Best First'.
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"

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


      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 <>

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://964706]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (1)
As of 2018-01-18 04:57 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (206 votes). Check out past polls.