Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: iterate through a hash with two keys

by BillKSmith (Vicar)
on Apr 30, 2013 at 02:12 UTC ( #1031299=note: print w/replies, xml ) Need Help??


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.
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}; }
OUTPUT:
a: 1 d: 4 h: 8 b: 2 f: 6
Bill

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1031299]
help
Chatterbox?
[Discipulus]: if i can ask: which is the minimal (cheapest) configuration to have some hardware running a webserver with minimal traffic and wifi connection?
[marto]: Raspberry Pi 3?
[Discipulus]: thanks under 50 neuros it's a good thing!
[Discipulus]: and it's GPIO how are seen by the OS? Perl can speak thougth them?

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2017-10-17 09:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (225 votes). Check out past polls.

    Notices?