in reply to print and display values

Please use <code> tags - this will allows the structure in your data to appear properly on this site.

You need to store the values retrieved into a hash. Assuming the values retrieved in a row are in @row, you can store them as:

my %cats; # .. loop to get a row # @row contains the retrieved row push $cats{ $row[1] }, $row[0]; # "Hash of arrays structure" # End of loop to get a row
Now you need to output the info retrieved:
for my $c (sort keys %cats){ my $values = $cats{ $c }; print "$c\t", join (" ", @$values), "\n"; }
UPDATE: Adding code needed to split the line after a a specified number of items:
my $ItemsPerLine=3; for my $c (sort keys %cats){ my $values = $cats{ $c }; print "$c\t"; for my $i(0..$#$values){ $i % $ItemsPerLine==0 and print "\n\t"; print $values->[$i], " "; } print "\n" unless $#$values % $ItemsPerLine==0; }

        "Think of how stupid the average person is, and realize half of them are stupider than that." - George Carlin