Someone on ruby-talk / ruby-lang.org wrote: >Note that as usual with benchmarks, you often don't implement things the >best way for each language. For all the Perl examples you gave, you're >using package variables, not lexicals. Lexicals are known to be slightly >faster (which may make a difference on this test). > >Here's the last one translated to use lexicals: > >my %a; >for (my $i=0; $i<1000000; $i++) { > $a{$i} = $i; >} >foreach my $key (keys(%a)) { > my $b = $a{$key}; >} >print "finished\n"; A note. Looping over ranges is generally faster than doing C-style loops as well as being less bug-prone. Therefore in current versions of Perl it is faster to write that loop as: foreach my $i (0..999_999) { $a{$i} = $i; } Or even using default variables you could inline it as: $a{$_} = $_ foreach 0..999_999; As a side benefit people make far fewer off-by-one and fencepost errors with foreach loops than they do with C-style for loops. These stylistic points apply perfectly well to Ruby as well. I am not absolutly positive that speed is better, but that would be my expectation. And the reliability benefit is also going to be there. The moral is this. Humans tend to make mistakes on explicit positional logic. Computers do not. Thus if your language supports it, it is generally best to develop a style with as little explicit positional logic as possible. Cheers, Ben