my @array=qw(a b c d e f g h); my %hash; for (my $idx=0; $idx<@array; $idx++) { $hash{$array[$idx]} = $idx; }