|
|
| Just another Perl shrine | |
| PerlMonks |
Re: 1 line array to hash converterby thpfft (Chaplain) |
| on Sep 21, 2001 at 14:44 UTC ( [id://113883]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
How about the less glamorous: my %hash = map { $_ => 1 } @array;which gets you off the separate declaration of %hash and is more versatile in the long run. Or to make your example a real oneliner: my %hash = map { $_ => 1 } (1..10);But i assume that in something real you'd be using an array that existed already.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||