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

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.