in reply to Re^2: Error: Can't use string as a hash ref
in thread Error: Can't use string as a hash ref
But adding use strict to your own script made it tell you your actual problem (whether you understood the error message or not), rather than letting it fall through to cause an error in the module. The problem wasn't with OO or your module; it was your use of the "bareword 'MyHandler'", as it says.
When you use a bareword (a bit of text without a sigil or quotes or anything else to give it context) in a place where barewords aren't specifically allowed (like hash keys or file descriptors), Perl (in non-strict mode) does its best to guess what you mean by it. In most cases, including this one, it turns the bareword into a string, here coming up with "MyHandler", which it happily passes as the argument to your module. Then the module finally chokes on it because it expects a hash (object) reference. Using strict warns you sooner, at the exact point of the problem.
Aaron B.
My Woefully Neglected Blog, where I occasionally mention Perl.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Error: Can't use string as a hash ref
by Nocturnus (Scribe) on Apr 28, 2012 at 17:12 UTC |