You can use qq() as an alternative double quote method, for example, when you have double quotes in a string. For instance:
"\"foo bar\""
Looks better when written
qq("foo bar")
When in a windows cmd command shell that uses double quotes, I often use qq() when I need interpolation. For instance:
perl -lwe "print qq($foo\n)"
The qq() operator - like many other perl operators such as s/// , qx() - is also convenient, as you demonstrate, because it can use only any character as a separator:
qq[this works] qq|as does this| qq
This is useful when you have many different delimiters per line. For instance:
qq!This is (not) "hard" to quote!
As for best practice, I would say that I use what is more readable.
source share