in reply to A Not so Simple Append
You mean like this?
#!/usr/bin/perl -w use strict; my %seen = (); while (<DATA>) { my ($one, $two) = split; $seen{$one} = [$two, exists $seen{$one} ? @{$seen{$one}} : () ]; } for my $key (keys %seen) { print $key, " ", join(", ", @{$seen{$key}}), "\n"; } __DATA__ a 1 a 2 a 3 a 4 b 1 c 1 d 1
Christian Lemburg
Brainbench MVP for Perl
http://www.brainbench.com
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: A Not so Simple Append
by merlyn (Sage) on Oct 03, 2000 at 04:14 UTC | |
by tilly (Archbishop) on Oct 03, 2000 at 04:51 UTC | |
by extremely (Priest) on Oct 03, 2000 at 05:25 UTC | |
by tilly (Archbishop) on Oct 03, 2000 at 06:37 UTC | |
by clemburg (Curate) on Oct 03, 2000 at 12:18 UTC | |
by merlyn (Sage) on Oct 03, 2000 at 17:52 UTC | |
by clemburg (Curate) on Oct 03, 2000 at 20:24 UTC | |
by tilly (Archbishop) on Oct 03, 2000 at 18:33 UTC | |
by merlyn (Sage) on Oct 03, 2000 at 18:46 UTC | |
by tilly (Archbishop) on Oct 03, 2000 at 18:47 UTC | |
|