how to read the multiple values from XML file using perl script?
i have the xml file like:
<Provisioning>
<Appliance>
<ID>1</ID>
<SiteID></SiteID>
<IPAddress>10.52.32.230</IPAddress>
</Appliance>
<Appliance>
<ID>1</ID>
<SiteID></SiteID>
<IPAddress>10.52.32.530</IPAddress>
</Appliance>
<Appliance>
<ID>1</ID>
<SiteID></SiteID>
<IPAddress>10.52.32.730</IPAddress>
</Appliance>...
</Provisioning>
and i have written the code like:
use XML::Simple;
use Data::Dumper;
my $xml = new XML::Simple;
my $peermas = $xml->XMLin($masapplications);
print "file contents: $peermas \n";
print Dumper($peermas);
@masipaddr =+ $peermas->{Appliance}->{IPAddress}; #{Provisioning}->{Appliance}->{IPAddress};
print "The MAS ip: @masipaddr \n";
i am very new to perl script and my code can read only one IP address not the remaining 2.
so what should i do in this case?? please reply soon…
thanks in advance.
You already have all info you need in your
$peermas. But if you need array of your IP addressed you may use:This map iterate on array of hashes
$peermas->{Appliance}and push each IPAddress from it into@massipaddr.