Using quote-like-operators or quotes in the perl's printf -
reading perl sources saw many times next construction:
printf qq[%s\n], getsomestring( $_ );
but usually written as
printf "%s\n", getsomestring( $_ );
the question:
- is here "good practice" correct way, , if yes
- when recommended use longer
qq[...]
vs"..."
- or pure timtowtdi?
the perlop doesn't mention this.
you can use qq()
alternative double quote method, such when have double quotes in string. example:
"\"foo bar\""
looks better when written
qq("foo bar")
when in windows cmd shell, uses double quotes, use qq()
when need interpolation. example:
perl -lwe "print qq($foo\n)"
the qq()
operator -- many other perl operators such s///
, qx()
-- handy demonstrate because can use character delimiter:
qq[this works] qq|as this| qq#or this#
this handy when have many different delimiters in string. example:
qq!this (not) "hard" quote!
as best practice, use whatever more readable.
Comments
Post a Comment