Wednesday, December 29, 2010

To get the index of an array element

my @array = qw(a b b c);
my %hash;
@hash{ @array } = 0..$#array;
print $hash{b}; # 1


SOURCE: http://stackoverflow.com

No comments: