I am running a script that gives me the following output:
user@host1::perl: ./1.pl
Are you sure you would like to delete all *.bak files that exist in: /dir/etc-test yes/no yes
No files were found
$VAR1 = {};
>>> Oper Sys: linux
>>> Platform: RedHat
>>> Hostname: host1
I am so far not able to figure out why the data is missing. This exact code was working and all I did to it was enclose it into a sub and add an if statement ($platform_in).
This script is getting quite long now so I am only adding the code for the call and the sub. If you want to see additional code I will post it all
my @nicdata = networkInfo($platform); sub networkInfo { my $platform_in = shift; my ($nics, %nic); if ($platform_in =~ /RedHat/) { $nics = qx |/sbin/ifconfig| or die("Can't get info from Linux +ifconfig: $!\n"); my @nics = split /(?<=\n)(?=\w)/, $nics; for (@nics) { my %nic; ($nic{device}) = $_ =~ /^(eth\d)\s/ or next; if (/\binet addr:([\d.]+)\s.+?:([\d.]+)\s.+?:([\d.]+)/) { $nic{ip} = $1; $nic{bcast} = $2; $nic{mask} = $3; #print "Device: $nic{device} has the IP Address of $ni +c{ip}\n\tMask: $nic{mask}\n\tBroadcast: $nic{bcast}\n"; } if (/^\s+ inet6 addr:\s*(\S+)/m) { $nic{ip6} = $1; #print "Device: $nic{device} also has IPv6 address of +$nic{ip6}\n"; } } } elsif ($platform_in =~ /SunOS/) { $nics = qx |/sbin/ifconfig -a| or die("Can't get info from Sol +aris ifconfig: $!\n"); my @nics = split /(?<=\n)(?=\w)/, $nics; for (@nics) { my %nic; ($nic{device}) = $_ =~ /^(fjgi\d)\s/ or next; if (/\binet addr:([\d.]+)\s.+?:([\d.]+)\s.+?:([\d.]+)/) { $nic{ip} = $1; $nic{bcast} = $2; $nic{mask} = $3; print "Device: $nic{device} has the IP Address of $nic +{ip}\n\tMask: $nic{mask}\n\tBroadcast: $nic{bcast}\n"; } if (/^\s+ inet6 addr:\s*(\S+)/m) { $nic{ip6} = $1; print "Device: $nic{device} also has IPv6 address of $ +nic{ip6}\n"; } } } # => ENABLE DEBUGGING MODE use Data::Dumper; print Dumper(\%nic); #return (\%nic); # Do all printing here.... # this statement needs work. # print "Device: $a\n\tIPv4: $b\n\tBcast: $c\n\tMask: $d\n\tIPv6: $e +\n"; }
In reply to Data::Dumper is returning empty by MikeDexter
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |