in reply to amalgamate similar lines
my @line; my %third_col; while( <> ) { chomp; my @col = split /\|/, $_, -1; my $key = join '|', @col[ 0, 1 ]; push @line, $key if not exists %third_col{ $key }; push @{ $third_col{ $key } }, $col[ 2 ]; } for ( @line ) { print $_ . '|' . join ',', @{ $third_col{ $_ } }; }
Update: fixed a sigil, thanks to Roy Johnson.
Makeshifts last the longest.
|
|---|