amarobin has asked for the wisdom of the Perl Monks concerning the following question:

I am new to perl and I would like to know why the following lines don't work on my pc.

perl -le 'print 2**255;' Can't find string terminator "'" anywhere before EOF at -e line 1.
I actually want to execute this line to see if bignum is found.
perl -Mbignum -le 'print 2**255;' Can't find string terminator "'" anywhere before EOF at -e line 1.

The version of perl is this: >perl -v This is perl, v5.10.0 built for MSWin32-x86-multi-thread Copyright 1987-2007, Larry Wall

Replies are listed 'Best First'.
Re: 'perl -le' not working on the command line
by bart (Canon) on May 26, 2011 at 10:47 UTC
    In the Windows command line you must use double quotes instead of single quotes for the shell.

    If you need double-quoting in Perl code, the easiest way is to use qq instead of real double quotes.

Re: 'perl -le' not working on the command line
by Bloodnok (Vicar) on May 26, 2011 at 10:48 UTC
    As the AM has already indicated, the fault lies with the shell, or what Windoze chooses to call it.

    The 'shell' ignores, or appears not to recognise, single quotes - try enclosing your CLI command in double quotes ...

    perl -Mbignum -le "print 2**255;"
    As I haven't had a Windoze box for quite a while, I can't actually demonstrate this.

    A user level that continues to overstate my experience :-))
      If I passed C source code to perl, the resulting error is not Perl's fault. Similarly, the error that results from presenting cmd with a bash command is not the shell's fault.
Re: 'perl -le' not working on the command line
by ww (Archbishop) on May 26, 2011 at 10:55 UTC

    I can't reproduce your results on either an Ubuntu or a Red Hat box.

    But that the error message may be misleading: It's what I see if I try your code on a win32 machine.

    So, if you're running 'doze, the correct quoting is:

    perl -le "2**255;"
          but probably a better way to "see if bignum is found" is to check this way:
    perldoc bignum

    Update: Duh! Missed the <c>perl -v...<c> in the OP. Nonetheless, using perldoc to test if a module is installed is apt to be less error prone.

Re: 'perl -le' not working on the command line
by Anonymous Monk on May 26, 2011 at 10:37 UTC
      To say it explicitly, cmd.exe, turns perl -le 'print 2**255;' into
      $ perl -le " 'print " "2**255;'" Can't find string terminator "'" anywhere before EOF at -e line 1.
      that is, the program is 'print , a syntax error. 2**255;' ends up in @ARGV.
Re: 'perl -le' not working on the command line
by locked_user sundialsvc4 (Abbot) on May 26, 2011 at 11:29 UTC

    Windows did try to come out with something that is vaguely closer to “a real shell,” which their marketroids promptly dubbed, “PowerShell.”     (Google it ...)   But I haven’t fooled with it much ... It is free, though, IIRC.

      And how does that help the new person who doesn't know anything about the shell he already has?
      I've heard rumors that you can also buy C shells from some lady down at the beach.