On 04/07/2016 12:28 AM, Kent Fredric wrote:
On 7 April 2016 at 07:20, Jonathon Fernyhough <jonat...@manjaro.org> wrote:
qq{} obviously wins when there would otherwise be a lot of escaping, but
are there any downsides of using this method more generally (other than
double-quotes being two characters shorter)? For example, is it "faster"
for Perl to parse a double-quoted string or does the compiler optimise
this out so the methods are fundamentally equivalent?
In that regards you can get a reasonable look at how perl interprets
your string with B::Deparse, partly because
the deparse reversal shows it more "natively"
perl -MO=Deparse -e' print q[Helloo]'
print 'Helloo';
perl -MO=Deparse -e' print qw[Helloo world]'
print 'Helloo', 'world';
perl -MO=Deparse -e' print qq[Helloo world]'
print 'Helloo world';
perl -MO=Deparse -e' print q[Helloo world $var]'
print 'Helloo world $var';
perl -MO=Deparse -e' print qq[Helloo world $var]'
print "Helloo world $var"; <-- note double quotes
perl -MO=Deparse -e' print qq[Helloo \Qwo)\E]'
print 'Helloo wo\\)';
and that supports my view of single quotes when not interpolating and
double quotes when interpolating!
uri
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/