in reply to Hash not getting updated
I assume this is just contrived code to ask a question, but, just in case, a hash slice makes the 'foreach' block unnecessary.
my @array = ( 'white', 'blue', 'yellow' ); my %hash; @hash{ @array } = @array;
Or, without the array:
my %hash; @hash{ 'white', 'blue', 'yellow' } = ( 'white', 'blue', 'yellow' );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hash not getting updated
by Madam (Sexton) on May 03, 2005 at 06:34 UTC | |
by CharlesClarkson (Curate) on May 03, 2005 at 14:23 UTC |