in reply to Algorithm needed
#!/usr/bin/perl -w use strict; my %seen; my %hash = (); while (<DATA>) { # split based on spaces my ($hex, $foo, $int) = split /\s+/; # use hash value as an array ref push @{$hash{$hex}}, $int unless $seen{$int}++; } for (keys %hash) { print "$_ = ", join(", ", sort @{$hash{$_}}), "\n"; } __DATA__ 0x130005d 1.253.54.1 11 0x130009c 1.253.54.2 12 0x130005d 1.253.54.1 14 0x130005d 1.253.54.1 11 0x130005d 1.253.54.1 10 0x130009c 1.253.54.2 12 0x130009c 1.253.54.2 14
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Algorithm needed
by LTjake (Prior) on Dec 06, 2002 at 00:57 UTC |