qq behaves just like double quotes " do, they interpolate variables, but they make it easy to include double-quotes in a string without the need to escape them.

Immediately after the qq you put some opening character and then the string lasts till the ending pair of that character. I usually use some form of a pair of characters (opening and closing curly braces or parentheses), but you can also use other characters as well.

Yes, even when you use # it works, but IMHO that's hard to read.

examples/qq.pl

  1. use strict;
  2. use warnings;
  3. use 5.010;
  4. my $name = "Perl";
  5. my $text = "The name of this programming language is \"$name\".";
  6. say $text;
  7. my $better = qq{The name of this programming language is "$name".};
  8. say $better;
  9. my $other = qq!The name of this programming language is "$name".!;
  10. say $other;
  11. say qq(The name of this programming language is "$name".);
  12. say qq[The name of this programming language is "$name".];
  13. say qq?The name of this programming language is "$name".?;
  14. say qq#The name of this programming language is "$name".#;

The above examples all print the same string:

The name of this programming language is "Perl".