Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Runtime Hash Variable access

by Hena (Friar)
on Mar 08, 2004 at 14:14 UTC ( [id://334816]=note: print w/replies, xml ) Need Help??


in reply to Runtime Hash Variable access

First, use code tags here, ok.

I assume you don't use 'use warnings' here? You neeed to use it catch problems like these. Eg you haven't declared any hashes. Should be like this:
%ABCDev = qw /A 1 B 2 C 3/;
But, i'm not sure if the loop will work either. You need to try it again. It might be better to save references into array.
@prods=(\%ABCDev,\%DEFDev,\%GHIDev); for($i=0;$i<=$#prods;$i++) { @prodkeys = keys %{$prods[$i]}; print "@prodKeys\n"; }

Replies are listed 'Best First'.
Re: Re: Runtime Hash Variable access
by Juerd (Abbot) on Mar 08, 2004 at 14:23 UTC

    %ABCDev = qw /A 1 B 2 C 3/;

    Technically, that *defines* (assigns to) %ABCDev, but it doesn't *declare* it. You declare a variable with my, our or use vars.

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

      You are right. Mainly ment that the wanted hash %ABCDev was empty due that assingment happened to scalar and not hash. And that using 'use strict' and 'use warnings' would have caught the mistake.

      I just don't always think that much about words than meaning (which in some cases can be somewhat obscure due to my lack of attention to words :D).
Re: Re: Runtime Hash Variable access
by spaceforsrini (Initiate) on Mar 08, 2004 at 15:17 UTC
    Your code worked fine. Except I had to change the prodKeys to prodkeys :-) Thanks for immediate reply

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-04-20 12:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found