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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |