sub get_colors_for_item { my ($dbh, item_id) = @_; my $sth = $dbh->prepare( 'SELECT color FROM item WHERE item_id = ?' ); $sth->execute( $item_id ); my @colors; while( my ($color) = $sth->fetchrow_array()) { push @colors, $color; } return @colors; }