in reply to Re: foreach (@array) s/x/y/ efficiency
in thread foreach (@array) s/x/y/ efficiency

This ends up actually taking longer to run than the original. I think that's because the s/// has to fly through the entire string of $material, where the loop version (original) stops (last out of loop) when it hits the match. (Not that I would really know for sure what I'm talking about.)

Replies are listed 'Best First'.
Re: Re: Re: foreach (@array) s/x/y/ efficiency
by chipmunk (Parson) on Jan 11, 2001 at 03:36 UTC
    Could you provide the data you used to compare the different solutions? I really was expecting mine to be faster, so I'd like to figure out what I did wrong. Thanks!

      It's the book of Luke from the NIV Bible. Each element of @material is setup ^\d\t\d\tLuke\t$chapter\$verse\$verse_text\n. And @key_phrases is just each key phrase from the material with a single space between the two words. (ex. $key_phrases[6153] = "not immediately";)