in reply to Multiple Hash values
Yes, you can. You even have the right approach in mind. All you need is a syntax nudge.
Hashes of Arrays and Arrays of Hashes can look a little odd at first but are intensely powerful structures if you take the time to get to know them.
#!/usr/bin/perl use strict; my %Hash; $Hash{a}[0]="i"; $Hash{a}[1]="ii"; $Hash{a}[2]="iii"; $Hash{b}[0]="iv"; $Hash{b}[1]="v"; $Hash{b}[2]="vi"; foreach my $var (sort keys %Hash) { print "$var,"; foreach my $val (@{$Hash{$var}}) { if (defined $val) { print "$val,"; } } } exit; __END__
|
|---|