Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Perl and arrays of arrays?

by aukjan (Friar)
on Aug 17, 2005 at 13:50 UTC ( [id://484427]=note: print w/replies, xml ) Need Help??


in reply to Perl and arrays of arrays?


I would attack this with a hash to filter out duplicates:
while(<FH>){ chomp; my @fields = split; my $ip = shift @fields; foreach ( @fields ){ $masterhash{$ip}{$_} = 1; } }
Now the hash will contain an unique IP as key with a hash as value of which the keys are uniqe aliases..
So now just print it out:
for my $ip ( keys %masterhash ){ print "$ip ", join (" ",keys %{$masterhash{$ip}}),"\n"; }
Hope this helps... (not tested)

Go Fish!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://484427]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-03-29 02:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found