rossta has asked for the wisdom of the Perl Monks concerning the following question:
I remember a one liner, that would populate the keys of the hash with the elements of the array, but now it escapes me (age?). I seem to remember it was something like:my @array = (1..10); my %hash = ();
But that doesn't work. Any ideas?%hash{@array} = (1) x scalar(@array};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: 1 line array to hash converter
by stefp (Vicar) on Sep 21, 2001 at 18:39 UTC | |
by rossta (Initiate) on Sep 21, 2001 at 18:55 UTC | |
|
Re: 1 line array to hash converter
by davorg (Chancellor) on Sep 21, 2001 at 18:48 UTC | |
|
Re: 1 line array to hash converter
by suaveant (Parson) on Sep 21, 2001 at 18:37 UTC | |
by jeffa (Bishop) on Sep 21, 2001 at 18:54 UTC | |
by davorg (Chancellor) on Sep 21, 2001 at 18:58 UTC | |
by Sifmole (Chaplain) on Sep 21, 2001 at 22:15 UTC | |
by clintp (Curate) on Sep 21, 2001 at 20:54 UTC | |
|
Re: 1 line array to hash converter
by thpfft (Chaplain) on Sep 21, 2001 at 18:44 UTC |