Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Not sure what you mean by "access each element", since the elements seem to be a variety of different structures, but here's how to get into the structure a couple levels. For everyone else's benefit, I added something into that hole at the bottom and then ran this through Data::Dumper first and eliminated a bunch of the whitespace at the left side to clean it up.

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"; }

In reply to Re: How to access hash of arrays values using perl by TJPride
in thread How to access hash of arrays values using perl by veerubiji

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 19:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found