in reply to Faster indexing an array

don't know if it's that much faster but it's IMHO better readable (i.e. more "perlish") =)

DB<112> @Y=qw(a b a) => ("a", "b", "a") DB<113> %Ypos=(); $i=0; => 0 DB<114> push @{ $Ypos{$_} },$i++ for @Y => "" DB<115> \%Ypos => { a => [0, 2], b => [1] }

please note that the debugger-shell has problems to handle lexical variables, that's why I omitted them.

And I avoided dereferencing, but I don't think it'll cost you much reintroducing it. (if needed)

But you should add my declarations in productive code.

Cheers Rolf

(addicted to the Perl Programming Language and ☆☆☆☆ :)

PS: from 5.14 on you can also write

push $Ypos{$_},$i++ for @Y