MikeDexter has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need help with small IF statement
by ikegami (Patriarch) on Jan 20, 2010 at 16:07 UTC | |
|
Re: Need help with small IF statement
by kennethk (Abbot) on Jan 20, 2010 at 15:59 UTC | |
by MikeDexter (Sexton) on Jan 20, 2010 at 16:13 UTC | |
by kennethk (Abbot) on Jan 20, 2010 at 16:23 UTC | |
|
Re: Need help with small IF statement
by molecules (Monk) on Jan 20, 2010 at 16:01 UTC | |
|
Re: Need help with small IF statement
by Ratazong (Monsignor) on Jan 20, 2010 at 16:02 UTC |