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