Fellow monks, I ask again for your help. This one's got me completely stumped...

Following is my code, verbatim:

local $network_ifs = `netstat -i | grep -Ev "lo|sit|link|Name" | cut - +f1 -d" " | uniq | sort -n`; foreach (split("\n", $network_ifs)) { push @tcp_utilization_metrics, "$_"; } %tcp_utilization_adapter_names = (); foreach $network_if (@tcp_utilization_metrics) { local $if_name = $network_if; if ($network_if =~ /en/) { $network_if =~ substr ($network_if, 2, 0, "t"); } if ($network_if =~ /tr/) { $network_if =~ substr ($network_if, 1, 2, "ok"); } if ($network_if =~ /at/) { $network_if =~ substr ($network_if, 2, 0, "m"); } print "$if_name: $network_if\n"; $tcp_utilization_adapter_names{"$if_name"} = "$network_if"; print "$tcp_utilization_adapter_names{$if_name}\n"; } foreach (@tcp_utilization_metrics) { print "$tcp_utilization_adapter_names{$_}\n"; }

And following is the program's applicable output (with empty lines indicated):

en0: ent0   
ent0        
en1: ent1   
ent1        
(empty line)
(empty line)

I've been over and through this code, and I just can't figure out what's wrong. Can anyone else see it? Many thanks and much appreciation!


In reply to Simple hash assignment...or is it? by arootbeer

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.