On Thu, 7 Apr 2016 16:28:36 +1200
Kent Fredric <kentfred...@gmail.com> 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\\)';
> 
> 
> 
> 

Not exactly. Perl converts the source code into an internal
representation. Since it does this only once, it is hard to determine
which is faster.

What Deparse does is scan the internal representation and convert it to
something readable. Its output is not the internal representation.


-- 
Don't stop where the ink does.
        Shawn

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to