in reply to Perl and arrays of arrays?
Looks like you need a hash of hashes instead. Something like this (untested):
You can use an array for the top level instead, and have an array of hashes. But if you have duplicate aliases, you'll want the hashes at the second level.my %master; while (<>) { my @line = split ' '; foreach my $alias ( @line[1..$#line] ) { $master{$line[0]}{$alias}++; } } foreach my $ip ( sort keys %master ) { print "$ip ", +join( ' ', sort keys %{$master{$ip}}), "\n"; }
-QM
--
Quantum Mechanics: The dreams stuff is made of
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl and arrays of arrays?
by Koolstylez (Scribe) on Aug 17, 2005 at 15:26 UTC | |
by QM (Parson) on Aug 17, 2005 at 15:43 UTC | |
by Koolstylez (Scribe) on Aug 17, 2005 at 19:51 UTC | |
by QM (Parson) on Aug 17, 2005 at 20:44 UTC | |
by Koolstylez (Scribe) on Aug 17, 2005 at 21:10 UTC |