in reply to Re^2: passing @ to sub and getting back hash
in thread passing @ to sub and getting back hash
$ perl -MData::Dumper -le' my @dc = ( "xxxx-123:xxxxxxABC,z", "xxxx-:xxxxxx,z", "xxxx-456:xxxxxx, +z", "xxxx-XXX:xxxxxxDEF,z", "xxxx-789:xxxxxxGHI,z" ); my %hash1 = map /^xxxx-(\d+):xxxxxx([^,]+),.+$/, @dc; my %hash2 = map { /^xxxx-(\d+):xxxxxx([^,]+),.+$/ ? ($1 => $2) : () } +@dc; print Dumper \%hash1, \%hash2; ' $VAR1 = { '123' => 'ABC', '789' => 'GHI' }; $VAR2 = { '123' => 'ABC', '789' => 'GHI' };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: passing @ to sub and getting back hash
by NetWallah (Canon) on Jan 01, 2008 at 04:12 UTC | |
by GrandFather (Saint) on Jan 01, 2008 at 05:03 UTC |