In perl you can use both qq(<text>) and "<text>" to create double quoted text. Is there any difference between the two?
(Same question for q(<text>) and '<text>')
No.
"<text>" is short for qq"<text>".
'<text>' is short for q'<text>'.
Quote-Like Operators
Deparse Perl programs to see how Perl interpreted you wrote. When you use the generalized quotes, you get back the single and double quotes:
$ perl -MO=Deparse -e '$s = q(abc)'
$s = 'abc';
-e syntax OK
$ perl -MO=Deparse -e '$s = qq/ab "c" d/'
$s = 'ab "c" d';
-e syntax OK
$ perl -MO=Deparse -e '$s = qq(abc$$)'
$s = "abc${$}";
-e syntax OK
Besides using these to allow the ' and " to appear in the string, I find them very handy for one liners so that the ' and " don't trigger shell problems:
% perl -le "print qq(PID is $$)"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With