Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: Re: Re: Re: Efficienty truncating a long stringby ysth (Canon) |
on Dec 18, 2003 at 10:03 UTC ( [id://315480]=note: print w/replies, xml ) | Need Help?? |
4-arg substr isn't optimized for void context. It will set up the replaced string to be returned regardless.
The lvalue substr doesn't actually return the string but a special lvalue indicating the offset and length. Creating this and setting it to '' involves a fair amount of overhead. Which is actually more efficient will probably depend on how much you are truncating.
In Section
Seekers of Perl Wisdom
|
|