On May 9, [EMAIL PROTECTED] said:

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

>> 1.  print qq/I said "Help me!!".\n/;
>>
>> 2.  print "I said "Help me!!".\n";
>>
>> 3.  print "I said /"Help me!!/".\n";

#1 works, but #2 and #3 do not.  I think you meant to use \" instead of
/" in #3.

qq() is double-quoted context, but it is a replacement for physical
double-quotes.  By using qq//, it's like / is now your quote.

Just like

  "he said "hi" to me"

is invalid, so is

  qq/he said /hi/ to me/

To get that to work, you'd need to backslash the quoting character:

  "he said \"hi\" to me"
  qq/he said \/hi\/ to me/

but that should be a sign that you should've chosen a different character.

Using qq(), qq[], qq{}, or qq<> allows you to nest the quotes:

  qq(I think (since I'm ill) I won't go to class today.)

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734

Reply via email to