Syntactic Confectionery Delight | |
PerlMonks |
dereference hash key object in access methodby gctaylor1 (Hermit) |
on Nov 09, 2008 at 06:25 UTC ( [id://722456]=perlquestion: print w/replies, xml ) | Need Help?? |
gctaylor1 has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to dereference a hash key inside an access method and cannot figure out why it's failing. I keep getting this error "Can't use string ("5") as a HASH ref while "strict refs" in use at Music.pm line 19." If I manually assign the value in the method it works and in another method I can print the value using the same syntax. The big picture is that I want to pass one value to the constructor and then use that value along with an access method to populate the second value in the constructor. This is possible when I use the hard coded value in the method. What concept is it that I am not understanding?
This is the line in question from the sub add_numbers method:
Here's my user/driver program:
Any clues on what I need to study?
Back to
Seekers of Perl Wisdom
|
|