in reply to Simple hash assignment...or is it?
I've rewritten what you have a little (the output is different, but I think I get the gist of what you're trying to do) so that the only shell is for the netstat command.
#!/usr/bin/perl use strict; my %adapter_names = (); for (split /\n/, `netstat -i`) { next if /lo|sit|link|Name/; /(\S+)/; # Takes first block of non-spaces, assigns to $1 my $interface = $1; my $adapter = $interface; $adapter =~ s/^en/ent/; # Add other substitutions here $adapter_names{$adapter} = $interface if !defined $adapter_names{$ad +apter}; } print "$_ : $adapter_names{$_}\n" for sort keys %adapter_names;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Simple hash assignment...or is it?
by arootbeer (Novice) on Nov 22, 2003 at 06:35 UTC |