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
use strict; use warnings; use 5.010; my $name = "Perl"; my $text = "The name of this programming language is \"$name\"."; say $text; my $better = qq{The name of this programming language is "$name".}; say $better; my $other = qq!The name of this programming language is "$name".!; say $other; say qq(The name of this programming language is "$name".); say qq[The name of this programming language is "$name".]; say qq?The name of this programming language is "$name".?; 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".
Published on 2021-02-23