[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] appending to two strings



On Mon, Aug 16, 1999 at 03:31:35PM -0700, Eli Evans wrote:
> 
> : > > Is there a way to do the following two lines in one line? :
> : > >
> : > > $string1 .= $append;
> : > > $string2 .= $append;
> :
> : i always thought the "." operator was higher overhead becasue it had
> : more storage management.  why not:
> 
> That's my understanding, too, but ...

You're both wrong. 
The string interpolation is slower than the dot.
In fact, I believe string interpolation is actually *implemented* in terms
of dot.


> : > ( $string1, $string2 ) = map { $_ . $append } ( $string1, $string2 );

Yes, the for loop is pretty snappy.
This map approach is only shown as a possibly "funner" WTDI.

-- 
John Porter


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe