On Wed, 9 May 2001 [EMAIL PROTECTED] wrote:
> Somebody please help me uderstand the deal with "qq". I have run tests
> on all three lines of code below and it turns out that #1 and #3 work
> but #2 does not. I am under the impression that "qq" acts as double
> quotes. So why doesn't #2 work isn't it the same as #1? NO
> COMPRENDE!!! Thanks, [EMAIL PROTECTED]
>
>
> > 1. print qq/I said "Help me!!".\n/;
> >
> > 2. print "I said "Help me!!".\n";
> >
> > 3. print "I said /"Help me!!/".\n";
qq is used so you don't need to escape nested double quotes in a string.
In the second example, Perl sees the nested double quotes and thinks they
match against the first set of double quotes. It would try to print
"I said "
Help me!!
".\n"
Obviously the second line would would flag all kinds of errors, like
barewords, no concatenation, etc.
Using qq// helps in this regard, combat ambiguity, and aids in reability.
-- Brett
http://www.chapelperilous.net/btfwk/
------------------------------------------------------------------------
Human kind cannot bear very much reality.
-- T.S. Eliot, "Four Quartets: Burnt Norton"