The stupid question is the question not asked | |
PerlMonks |
How to access each char in a string most quickly?by llancet (Friar) |
on Jul 03, 2009 at 01:39 UTC ( [id://776892]=perlquestion: print w/replies, xml ) | Need Help?? |
llancet has asked for the wisdom of the Perl Monks concerning the following question:
I attempted to find a quicker way to access each char in string. I tested two methods. One is to split into an array, and the other way is to substr.
I have tested these two methods. It seems that foreach() is significantly more quickly, but split// costs too much time. split: 4826/s substr: 18214/s pre-splitted, only foreach in benchmark: 78247/s So, is there any quicker way to iterate chars?
Back to
Seekers of Perl Wisdom
|
|