$hash{ substr $_, 0, 4 } .= $/ . $_ for 1 .. 1000000; $n=0; print time; for (1 .. 1000000) { next unless exists $hash{ substr $_, 0, 4 } and 1+index( $hash{ substr $_, 0, 4 }, $/.$_ ); $n++; } print time, $/, $n; 1069427237 1069427281 1000000