in reply to Re: Algorithm Efficiency vs. Specialized Hardware?
in thread Algorithm Efficiency vs. Specialized Hardware?

Wondering why the original benchmark didn't work as it should, lhoward said:
> (I think its some sort of quoting/scoping problem, > but I'm not sure exactly what).
It's a scoping problem. The quoted code (Grep2) isn't accessing the same %url hash as the other two pieces of code, which you could tell if you had warnings on. You get a warning about a "Useless use of list slice in void context" for that code.

Why aren't the others in void context? Grep is accessing the lexical %url because it's lexical to the file scope, and the Grep subroutine is defined in this file. And Grep3 (the third one) is accessing the same lexical %url because the anonymous sub acts as a closure (I think).

So Grep2 is looking at a different (not defined) %url, and is thus not actually a very good test in terms of benchmarking. :)