Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: hash name as a variable?by samtregar (Abbot) |
on Sep 15, 2004 at 20:52 UTC ( [id://391291]=note: print w/replies, xml ) | Need Help?? |
Ronnie, you've stumbled onto one of the darker corners of Perl, the difference between lexical (my) variables and package/global (our, local) variables. The critical expression here is:
This code attempts to use $DB_name as a symbolic-reference to find the hash to be indexed. Strict-mode forbids symbolic-references because they don't work with lexical (my) variables. When you turn off strict you get the package variable %IWSTEST (or whatever is in $DB_name) which doesn't exist since you declared your hashes with my(). Ok, so now you know what the problem is, how should you solve it? Here are two options:
Give it a try and post a new question if you're still having trouble. -sam
In Section
Seekers of Perl Wisdom
|
|