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