in reply to Re: Re: Simple hash assignment...or is it?
in thread Simple hash assignment...or is it?
Perhaps you could tell us what is your expected hash output. I highly suspect that you want the following instead in your code (swap the key-value in the hash) -use strict; use Data::Dumper; my $network_ifs = `netstat -i | grep -Ev "lo|sit|link|Name" | cut -f1 +-d" " | uniq | sort -n`; my @tcp_utilization_metrics = split '\n', $network_ifs; my %tcp_utilization_adapter_names; foreach my $network_if (@tcp_utilization_metrics) { next if ! $network_if; # ignore empty lines if any my $if_name = $network_if; if ($network_if =~ /en/) { substr($network_if, 2, 0) = "t"; # insert 't' } elsif ($network_if =~ /tr/) { substr($network_if, 1, 2) = "ok"; # replace 'ok' } elsif ($network_if =~ /at/) { substr($network_if, 2, 0) = "m"; # insert 'm' } # insert hash entries $tcp_utilization_adapter_names{$if_name} = $network_if; } # investigate the hash foreach (keys %tcp_utilization_adapter_names) { print "$tcp_utilization_adapter_names{$_}\n"; }
# insert hash entries $tcp_utilization_adapter_names{$network_if} = $if_name;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Simple hash assignment...or is it?
by arootbeer (Novice) on Nov 22, 2003 at 01:17 UTC | |
by Roger (Parson) on Nov 22, 2003 at 01:21 UTC | |
by liz (Monsignor) on Nov 22, 2003 at 10:14 UTC | |
|
Re: Re: Re: Re: Simple hash assignment...or is it?
by arootbeer (Novice) on Nov 22, 2003 at 01:22 UTC |