in reply to Problem using object references as hash keys
You can't use an object as the key to a hash; Perl automatically converts it to a string, and so you're trying to call a method on a string. Perl figures maybe you want to use symbolic references, where the string has the name of the class you want to use or the variable you want to dereference, but it can't find the method that way, so it fails with the error message you saw. If you used warnings and strict, Perl would have done a better job of warning you about this.
You can store objects in arrays, or as the values in a hash. You should be able to use one of those techniques to get your code to do what you want.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Problem using object references as hash keys
by jlf (Scribe) on Jun 10, 2004 at 00:12 UTC |