in reply to Getting the hash in this format
Hello ash_86, and welcome to the Monastery!
You can use the pairwise function from List::MoreUtils:
#! perl use strict; use warnings; use List::MoreUtils 'pairwise'; use Data::Dump; my @array1 = qw(red blue green); my @array2 = qw(black orange white); my %hash = pairwise { $a => $b } @array1, @array2; dd \%hash;
Output:
21:57 >perl 977_SoPW.pl { blue => "orange", green => "white", red => "black" } 21:57 >
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Getting the hash in this format
by ash_86 (Initiate) on Aug 23, 2014 at 12:09 UTC | |
by Athanasius (Archbishop) on Aug 23, 2014 at 12:21 UTC | |
by ash_86 (Initiate) on Aug 23, 2014 at 13:30 UTC |