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

for each block I will have different br_ip

I don't understand what you mean, your output has different br_ips. Un-comment this to see each block being searched

 #print "Searching for $br_ip\n";
poj

Replies are listed 'Best First'.
Re^4: need help with for loop within an xml
by deep27ak (Novice) on Sep 15, 2015 at 08:17 UTC
    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?
      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