http://qs321.pair.com?node_id=311569


in reply to Re: rearranging text
in thread rearranging text

This leads to possibly ugly output as there will be an extra comma in the output

Also will a value appear more than once, and should the values be sorted as well? Im thinking a HoH might be overkill, but another (better?) way to do it.

my %all; while (<>) { s/\s+//g; my($k, $v) = split /,/; next unless defined $k and defined $v; $all{$k}{$v}++; } for ( sort keys %all ) { print "$_, ", join(', ', sort keys %{ $all{$_} }), "\n"; }

use perl;