http://qs321.pair.com?node_id=744213


in reply to Hash value interpolation

qSorry if I double posted... Thanks Ikegami, your idea/solution gets me further; however, now I do not get any output. Looks like I'm still doing something wrong. below is the test code I'm using: would apreciate the extra help. Thanks again!
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^2: Hash value interpolation
by jasonk (Parson) on Feb 16, 2009 at 22:11 UTC

    Read the help other people have given you already, you still aren't calling geth() anywhere.


    www.jasonkohles.com
    We're not surrounded, we're in a target-rich environment!
      I can't believe I missed that. Thanks Jason for pointing that out and my oppologies for the oversight! It actually works after all. Thanks to Ikegami as well for the original solution