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.


In reply to Re^3: Error: Can't use string as a hash ref by aaron_baugher
in thread Error: Can't use string as a hash ref by Nocturnus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.