in reply to How to access hash of arrays values using perl
use strict; use warnings; my $nested = { 'Systemreaction' => [ { 'Data' => 'x' }, { 'Data' => 'x' } ], 'Service' => [ { 'Customers' => [ { 'SW' => [ { 'Path' => '/work/servi +ce.xml', 'Service' => 'ASOC' } ] } ], 'Id' => 'SKRM', 'Name' => ' Control unit', 'Suppliers' => [ { 'SW' => [ { 'Path' => '/work/servi +ce.xml', 'Service' => 'b7a' }, { 'Path' => '/work/servi +ce1.xml', 'Service' => 'b7b' }, { 'Path' => '/work/servi +ce2.xml', 'Service' => 'b5' } ] } ], 'Des' => 'Control the current through the pipe' }, { 'Customers' => [ { 'SW' => [ { 'Path' => '/work/servi +ce.xml', 'Service' => 'SDCR' } ] } ], 'Id' => 'ADTM', 'Name' => ' Motor Drivers and Diognostics', 'Suppliers' => [ { 'HW' => [ { 'Type' => 'W', 'Path' => '/work/hardw +are.xml', 'Nr' => '18', 'Service' => '1' }, { 'Type' => 'B', 'Path' => '/work/hardw +are.xml', 'Nr' => '7', 'Service' => '1' }, { 'Type' => 'k', 'Path' => '/work/hardw +are.xml', 'Nr' => '1', 'Service' => '1' } ] } ], 'Des' => 'It delivers actual motor speed' } ] }; for my $service (@{$nested->{'Service'}}) { print "$service->{'Name'}\n"; } for my $system (@{$nested->{'Systemreaction'}}) { print "$system->{'Data'}\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to access hash of arrays values using perl
by veerubiji (Sexton) on Dec 15, 2011 at 22:03 UTC | |
by TJPride (Pilgrim) on Dec 15, 2011 at 22:31 UTC |