develooper Front page | perl.perl5.porters | Postings from March 2000

Re: [ID 20000330.052] Use of uninitialized value in concatenation (.)

Tom Christiansen
March 30, 2000 20:14
Re: [ID 20000330.052] Use of uninitialized value in concatenation (.)
Message ID:
>Tom Christiansen writes:
> > That is, however, what's happening:
> > 
> > % perl -MO=Deparse,-q -e '@scalar = @array = (1..10); print "this $sc<SNIP>
> > @scalar = (@array = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
> > print 'this ' . $scalar . ' and that ' . join($", @array) . "\n";

>Many years ago when I started doing Perl I picked up the idea that it
>is always more efficient to do double-quote interpolation than
>spelling it out with '.' between each element.  Of course, that was in
>the days of Perl4.  I assume that is no longer a concern?  

The v4 compiler didn't do at compile time the things the
v5 compiler does.

>Was it
>ever, or was I misinformed?  I've done a lot of Perl hacking, but have
>never spent time digging around in the actual interpreter itself.

These days, it's the compiler you should be thinking about here.
By which point, the interpreter just does what it's told.

>I also was told that if there are no variables to be interpolated to
>always use single quotes rather than double quotes, as the extra
>parsing required was expensive.  Is/was this true?

As far as "expensive" goes, that one belongs up there with the
advice to eschew comments and whitespace as it takes longer to parse
them.  There may be semantic difference to consider, of course.
Still, double quotes tend to stand out better than single ones.
Notice how many technical book publishers get their single vs back
quotes completely messed up.  I wouldn't be surprised if there
weren't folks who used double quotes just so they could see them

--tom Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About