in reply to Re: Generating Hash-of-List using map?
in thread Generating Hash-of-List using map?
DB<148> %hash=() DB<149> @CELLS => ("A-1", "A-2", "A-3", "A-4", "B-5", "B-6", "C-7", "C-8", "A-9") DB<150> %hash = map { /^([^-]*)-(.*)$/; if( $1 eq ($a//'-') ) { push + @$b, $2; () } else { ( $a = $1 => $b = [ $2 ] ) } } @CELLS; => ("B", [5, 6], "C", [7, 8], "A", [9])
oops, indeed! ;-)
Cheers Rolf
( addicted to the Perl Programming Language)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Generating Hash-of-List using map?
by hdb (Monsignor) on Sep 24, 2013 at 06:17 UTC | |
by LanX (Saint) on Sep 24, 2013 at 10:19 UTC |