Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Hash value interpolation

by csarid (Sexton)
on Feb 16, 2009 at 21:41 UTC ( #744213=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://744213]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2022-05-17 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (68 votes). Check out past polls.

    Notices?