Welcome to the Monastery, deep27ak!

At a glance, it appears as though you've got numerous issues with your code, including undefined variables, an erroneous }, repeatedly reassigning over a variable without using it in loops etc.

Please post enough of a sample of the XML file you're using as input that will satisfy a single pass of the script. Without that, it's too time consuming to reconstruct the code properly.

Also, get in the habit of using proper indenting. It'll help you greatly, and it'll help us work with what you've got.

Here's an example:

use strict; use warnings; use XML::Simple; my $xml = do {local $/='';'network.xml'} ; my $servers = XMLin($xml, ForceArray => 1); my %seen; foreach my $server (@{$servers->{server}}) { my $brlist; my $corebrip; my $brmask; my $brip; my $num; my $brlan; my @node = $server->{NodeName__1} . "\n"; my $lanip = $server->{CoreLanIP_1__1} ; my @mask = $server->{CoreLanNetmask_1} . "\n"; my $network = join("/", $lanip, @mask); $network =~ s/.[0-9]*\//.0\//g; push(my @networklist, $network) if ! $seen{$network}++; $brlan = $server->{BRLAN} ; if ( $brlan eq "y" ) { $brip = $server->{BR_IP}; $num = $server->{CoreLanNum} ."\n" ; } my @brnwlist; for my $n (1..$num){ $corebrip = $server->{'CoreLanIP_'.$n.'__1'} ; $brmask = $server->{'CoreLanNetmask_'.$n} ."\n"; } if ( $corebrip eq $brip ){ $brlist = join ("/", $brip, $brmask) ; $brlist =~ s/.[0-9]*\//.0\//g; push( @brnwlist, $brlist) unless $seen{$brlist}++; } else { print "coreip doesnot matches brip\n"; } } for $a (@brnwlist) { if ( $a ne "") { print "empty array"; my $vnum = $server->{CoreVlanNum} ."\n" ; for my $i (1..$vnum){ my $vlanip = $server->{'CoreVlan_IP_'.$i} ; my $vmask = $server->{'CoreVlan_Netmask_'.$i} ."\n"; if ($vlanip eq $brip){ my $vlist = join ("/", $brip, $vmask) ; $vlist =~ s/.[0-9]*\//.0\//g; push(my @vnwlist, $vlist) if ! $seen{$vlist}++; print @vnwlist; } } } }

-stevieb


In reply to Re: Use of uninitialized value $brip in join or string at script.pl line 50 by stevieb
in thread Use of uninitialized value $brip in join or string at script.pl line 50 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.