My output prints with a warning. I was told yesterday in cb to put the following code into an if statement.
"if (the ipv4 stuff is defined) {do all the fun printing}"
The sub does a push @nics, \%nic; return @nics; So my question is should the if be the outer loop or the for statement?

for my $nic (networkInfo()) { if ($nic->{device}) { print "DeviceMain: $nic->{device} has IP Address $nic->{ip}\n" . "\tMask: $nic->{mask}\n" . "\tBroadcast: $nic->{bcast}\n"; print "DeviceMain: $nic->{device} also IPv6 address $nic->{ip6}\n" +; } }

The output I am getting is as follows:

Are you sure you would like to delete all *.bak files that exist in: / +dir/etc-test [yes/no] yes No files were found >>> Oper Sys: linux >>> Platform: RedHat >>> Hostname: host1 Device: eth0 also has IPv6 address of xxxx::219:x9xx:xxxx:8091/64 Device: eth1 has the IP Address of xx.xx.xx.xx Mask: xx.xx.xx.xx Broadcast: xx.xx.xx.xx Device: eth1 also has IPv6 address of xxxx:80x0:22x:225:219:xxxx:xxxx: +808x/64 Use of uninitialized value in concatenation (.) or string at ./sec-tes +t.pl line 20 (#1) (W uninitialized) An undefined value was used as if it were alread +y defined. It was interpreted as a "" or a 0, but maybe it was a mi +stake. To suppress this warning assign a defined value to your variables. To help you figure out what was undefined, perl tells you what ope +ration you used the undefined value in. Note, however, that perl optimiz +es your program and the operation displayed in the warning may not necessa +rily appear literally in your program. For example, "that $foo" is usually optimized into "that " . $foo, and the warning will refer +to the concatenation (.) operator, even though there is no . in your program. DeviceMain: eth0 has IP Address Mask: Broadcast: DeviceMain: eth0 also IPv6 address xxxx::219:x9xx:feeb:8091/64 DeviceMain: eth1 has IP Address xx.xx.xx.xx Mask: xx.xx.xx.xx Broadcast: xx.xx.xx.xx DeviceMain: eth1 also IPv6 address xxxx:xxc0:22x:225:219:x9xx:xxxx:808 +x/64

In reply to Need help with small IF statement by MikeDexter

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.