in reply to Re^2: iterate through a hash with two keys
in thread iterate through a hash with two keys
This may be what you want.
OUTPUT:use strict; use warnings; my $label1 = 'L1'; my $label2 = 'L2'; my %hash; @hash{'a' .. 'h'} = ( {$label1 => 1 }, {$label1 => 2 }, {$label2 => 3 }, {$label1 => 4 }, {$label2 => 5 }, {$label1 => 6 }, {$label2 => 7 }, {$label1 => 8 }, ); while ( my( $key,$subhash ) = each %hash) { print "$key: $subhash->{$label1}\n" if exists $subhash->{$label1}; }
a: 1 d: 4 h: 8 b: 2 f: 6
Bill
In Section
Seekers of Perl Wisdom