Richard Lee wrote:

Thanks John for detailed explanation!!

I just dont' understand why \ (also didn't know that within [ ], \ has to be escaped.) needs to be watch out for within " " ..

\ use can be tricky, for example:

$ perl -le"print 'hello'"
hello
$ perl -le"print 'he\llo'"
he\llo
$ perl -le"print 'he\\llo'"
he\llo
$ perl -le"print 'hello\'"
Can't find string terminator "'" anywhere before EOF at -e line 1.
$ perl -le"print 'hello\\'"
Can't find string terminator "'" anywhere before EOF at -e line 1.
$ perl -le"print 'hello\\\'"
hello\
$ perl -le"print 'hel'lo'"
Bad name after lo' at -e line 1.
$ perl -le"print 'hel\'lo'"
hel'lo

And that is in a single quoted string where there is no interpolation.

Read the "Gory details of parsing quoted constructs" section of perlop.pod:

perldoc perlop



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to