Do you know where your variables are? | |
PerlMonks |
Re: Perl Hashesby johngg (Canon) |
on Apr 24, 2007 at 10:29 UTC ( [id://611687]=note: print w/replies, xml ) | Need Help?? |
You can but there are two problems with your code. First, variables are not interpolated inside qw{ ... } so you are just getting the literal variable name so you need to set up the hash using key/value pairs in a list. Second, you need to disambiguate the $dw from the '_VAR' because $dw_VAR is also a valid variable name; you can do this by saying ${dw}_ARG. You are setting up a hash reference and it is probably less confusing if you use the { key => value, ... } anonymous hash constructor. It is a good idea to always do use strict; and use warnings at the top of your code. That would help you catch things like undeclared variables.
I hope this is useful. Cheers, JohnGG
In Section
Seekers of Perl Wisdom
|
|