But don't do that. The code works, meaning that you will get a hash called %hashname21 if the value of $countit is 21. But it's much, much, much cleaner to use a hash of hashes or an array of hashes, like this:${"hashname".$countit}{FILE} = $file;
These versions will also work when using strict, whereas the version using symbolic references will not. I generally avoid using symbolic references unless I can clearly articulate why I need them instead of hard references (and offhand, I can't think of an instance where I could). For more information about this topic, see perlref.$hashes{$countit}->{FILE} = $file; # hash of hashes version $hashes[$countit]->{FILE} = $file; # array of hashes version
-- Mike
--
just,my${.02}
In reply to Re: How to use variable in Hash title
by thelenm
in thread How to use variable in Hash title
by itsmrchris
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |