in reply to Re^5: Help understand why this grep does not work
in thread Help understand why this grep does not work
DB<126> %hash = map { my ($m)=/^(\w\s+\d)/; $m => [ grep {/^$m/} @da +ta2 ] } @data1 => ("a 1", [], "a 2", ["a 2 Y"], "a 3", ["a 3 R"]) DB<127> %hash = map { my $k=$_ ; $k => [ grep {/^$k/} @data2 ] } map + { /^(\w\s+\d)/} @data1 => ("a 1", [], "a 2", ["a 2 Y"], "a 3", ["a 3 R"]) DB<128> %hash = map { /^(\w\s+\d)/; $1 => [ grep {/^$1/} @data2 ] } +@data1 => ("a 1", [], "a 2", ["a 2 Y"], "a 3", ["a 3 R"])
see also Generating Hash-of-List using map?
Cheers Rolf
( addicted to the Perl Programming Language)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Help understand why this grep does not work
by drmrgd (Beadle) on Nov 02, 2013 at 17:10 UTC |