On 15 January 2011 07:52, Emeka <emekami...@gmail.com> wrote:

> # perl -le '$str =  "the cat sat on the mat";print substr( $str, 4, -4 )'
> Can't find string terminator "'" anywhere before EOF at -e line 1.
>
> rmicro@RMICRO-PC C:\Program Files\xampp
> #
>
> It failed to work for me. Why?

Because you can't use single quotes for the script-string in Windows
cmd.exe.  If you must work in the command line, then you can either
escape all your double quotes within the string or use
qq~double-quoted string~ , where "~" can be any ascii character that
is not in the string itself.

perl -le "$str =  qq~the cat sat on the mat~; print substr( $str, 4, -4 )"

If I were beginning with Perl, I certainly would not practise in the
console but get an editor, such as  SciTE

<http://www.scintilla.org/SciTE.html>

and run the scripts from the editor (using F5) in the case of SciTE.

JD

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to