in reply to How to improve my code? main concern:array as hash element
You probably need
update: fixed typo
Hash values can only be scalars. An array reference is a scalar so we can use that.my %gp = ( ... Gi => \@gi, # an array ref Gt => \@gt, );
In your while loop you will first need to test if it is an array ref and, if so, dereference it. Something like
(not tested)... $j = $gp{$i}; my @values; if (ref $j eq 'ARRAY'){ @values = @{$gp{$i}}; } else { @values = ($j); } for $val (@values){ ...
update: fixed typo
In Section
Seekers of Perl Wisdom