in reply to Algorithm needed
You can then access the ints by using the hash values as array refs. For instance, to print the output:#!/usr/bin/perl -w use strict; 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; }
for (keys %hash) { print "$_ = ", join(", ", sort @{$hash{$_}}), "\n"; }
elusion : http://matt.diephouse.com
Update: D'oh! Missed the part about ints being unique. merlyn saw it though.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Re: Algorithm needed
by merlyn (Sage) on Dec 05, 2002 at 23:26 UTC | |
by sauoq (Abbot) on Dec 05, 2002 at 23:36 UTC | |
by merlyn (Sage) on Dec 06, 2002 at 00:28 UTC | |
by sauoq (Abbot) on Dec 11, 2002 at 20:06 UTC | |
|
Re: Re: Algorithm needed
by The_Rev (Acolyte) on Dec 05, 2002 at 23:26 UTC |