Thanks very much for your reply. I understood this loop
for my $n (1..$num){ my $ip = $server->{'CoreLanIP_'.$n.'__1'}; if ($ip eq $br_ip){ my $mask = $server->{'CoreLanNetmask_'.$n};

which did solve one of my problem of searching all the values as per 'corelannum'

As of now
foreach my $n (1..$num){ my $corebrip = $server->{'CoreLanIP_'.$n.'__1'} ; my $brmask = $server->{'CoreLanNetmask_'.$n} ."\n"; if ($corebrip eq $br_ip){ print join ("/", $br_ip, $brmask);
I get the below output
192.169.73.1/255.255.255.0 192.169.73.1/255.255.255.0 192.169.73.2/255.255.255.0 192.169.73.2/255.255.255.0 192.169.73.3/255.255.255.0 192.169.73.3/255.255.255.0 192.169.73.4/255.255.255.0 192.169.73.4/255.255.255.0 192.169.73.5/255.255.255.0 192.169.73.5/255.255.255.0 192.169.73.6/255.255.255.0 192.169.73.6/255.255.255.0
so it is searching the complete xml at once as the data I have posted is only one block...so How can I make the script to search block by block?

For each block it should search for all these variables and perform as I say then move to next block as I guess that would simplify things?

like for each block I will have different br_ip, CoreLanIP_'.$n.'__1' and  CoreLanNetmask_'.$n

So for each block it should search corelanip and if it matches br_ip then use the equivalent corelannetmask


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

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.