in reply to from array to hash
As for converting the array into a hash while preserving the previous contents something like this will do the job nicely:my @a = qw( a b c d ); # delete a & c splice(@a, 0, 1) splice(@1, 1, 1)
This preserves the previous contents of %b while adding keys for @a into %b.my @a = qw( a b c d ); my %b = ( 'e' => 2 ); %b = (%b, map { $_ => 1} grep defined, @a);
|
|---|