in reply to Re: Simple Table structure to file
in thread Simple Table structure to file

Actually, now I think about it, as you're potentially dealing with duplicates (I assume that's why you're using a %seen hash) then a hash of hashes might be simpler.

my %data; while (<IN>) { chomp; my @vals = split /;/; $data{$vals[0]}{$vals[1]}++; }

You then have a hash where the keys are your first set of values (12, 01, etc) and each value in the hash is reference to another hash where the keys are the second (longer) values and the values are the number of times each of those values appears in the data (which, I think, can be ignored for your purposes).

Then you can get the output you want like this:

foreach my $key (keys %data) { print "$key;"; print join(';', keys %{$data{$key}}); print "\n"; }
--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg