I downloaded that code and ran it as is, and got the following:
Using a hash as a reference is deprecated at test.pl line 20. Using a hash as a reference is deprecated at test.pl line 21. Using a hash as a reference is deprecated at test.pl line 27. Using a hash as a reference is deprecated at test.pl line 28. Using a hash as a reference is deprecated at test.pl line 33. Using a hash as a reference is deprecated at test.pl line 34. Using a hash as a reference is deprecated at test.pl line 35. Using a hash as a reference is deprecated at test.pl line 36.
The warnings about using a hash as a reference are from any line where you've got the following syntax: %hash_ref_name->{keyname}. That's because you're using the wrong sigil. It should be $hash_ref_name->{keyname} (note, the $ instead of the %). But you're also using a named hash, not a hashref, so you don't need the '->' operator. So the correct syntax is actually: $hashname{keyname}. Note the use of '$', and the absence of '->'.
The next issue is the difference between your expected output and the actual output...First quote your keys so they don't get numerified.
So when you print @DataRatesHash{ '2.0', '1.0', '5.5', '48.0' } (please excuse the shorthand), you get the expected 1012.
Dave
In reply to Re: hash, deref & looping problem
by davido
in thread hash, deref & looping problem
by ramya2005
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |