in reply to Re: Hash value interpolation
in thread Hash value interpolation
use warnings; use strict; my $COLOR=2; my $hm=""; my $ht=""; my %h1 = ( "1" => "blue" ); my %h2 = ( "2" => "green" ); if ( $COLOR == 1 ) { $ht=\%h1; } elsif ( $COLOR == 2 ) { $ht=\%h2; } sub geth { while ((my $key, my $value) = each(%$ht)) { if ( $key == $COLOR ) { $hm=$value; } } print "$hm\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Hash value interpolation
by ikegami (Patriarch) on Feb 16, 2009 at 21:59 UTC | |
by csarid (Sexton) on Feb 17, 2009 at 22:44 UTC | |
by ikegami (Patriarch) on Feb 17, 2009 at 23:01 UTC | |
by csarid (Sexton) on Feb 18, 2009 at 05:14 UTC | |
|
Re^3: Hash value interpolation
by kyle (Abbot) on Feb 16, 2009 at 21:16 UTC |