Problems? Is your data what you think it is? | |
PerlMonks |
Re: Optimizing a string processing subby blokhead (Monsignor) |
on Jan 08, 2003 at 19:56 UTC ( [id://225340]=note: print w/replies, xml ) | Need Help?? |
Not sure if this is faster, but it might be, as it doesn't use nested loops.
This prints:
I notice your algorithms give 3 matches for 'bilbo' and 'baggins'. I think this is because both 'b's in bilbo match inside baggins. I'm not sure if this is correct behavior by your specifications or not. Update: To speed up your score2 sub, consider using index($word2, $a) > 0 instead of the regex match. Changing this alone made it approximately as fast as your initial score sub for me. blokhead
In Section
Seekers of Perl Wisdom
|
|