in reply to Re^3: need help with for loop within an xml
in thread need help with for loop within an xml

Yeah sorry my bad I just verified with different with different subnet values and it IS picking the correct values.

Can you please help me understand the modification you made to XML:Simple

as below
my $xml = do {local $/='';'file.xml'} ; #my $servers = XMLin('file.xml'); my $servers = XMLin($xml, ForceArray => 1);
What does this do?

Replies are listed 'Best First'.
Re^5: need help with for loop within an xml
by poj (Abbot) on Sep 15, 2015 at 14:50 UTC
    my $xml = do {local $/='';<DATA>} ; reads the lines following __DATA__ into a string.
    Since your XML is in a separate file use my $servers = XMLin('file.xml',ForceArray => 1); and remove the __DATA__ line and all the lines following.

    ForceArray=1 ensures $servers->{server} is an arrayref even if there is only one server block in the file.

    See OPTIONS in XML::Simple
    poj