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:
Now you need to output the info retrieved: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
UPDATE: Adding code needed to split the line after a a specified number of items:for my $c (sort keys %cats){ my $values = $cats{ $c }; print "$c\t", join (" ", @$values), "\n"; }
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
In reply to Re: print and display values
by NetWallah
in thread print and display values
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |