Why are you printing the IP address when you have haven't found one (i.e. when the inner if hasn't been entered)? Don'thide errors. Please use use strict; use warnings;!
use strict; use warnings; my $ifconfig = "ifconfig -a"; my @nic = qx |$ifconfig| or die("Can't get info from ifconfig: $!\n"); for (@nic){ if (my ($device) = /^fjgi(\d)/){ if (my ($ip) = /inet ([\d.]+)/){ print "Device $device has the IP Address of $ip\n"; } } }
I have two IF statements that work on their own but when I place them both into my foreach loop, the second IF gets skipped over
Are you sure there's a line that both starts with fjgi and contains inet? I'm not familiar with the output of ifconfig, but I suspect that isn't the case.
In reply to Re: Need help with a nested IF statement
by ikegami
in thread Need help with a nested IF statement
by MikeDexter
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |