You asked for advice on OO. If you're going to encapsulate functionality, you should not affect things outside the scope of your module. By setting a handler for all warn calls the way you have done, all of the warning messages that might be generated by the script using your module would also be trapped. It may be what you want in your scenario, but if I personally were to use a module and suddenly have all of my calls to warn() stop working as expected, I would at first be confused, then annoyed once I found out what the problem was and had to rewrite my code to account for this. The only time I could see that you would want to rewrite the warn handler on a global scale would be if you were writing a message specificly for the purpose of trapping warn messages.

Just my 2 cents.

cephas

In reply to Re: Re: Re: First steps in OO-Perl , suggestions please! by cephas
in thread First steps in OO-Perl , suggestions please! by kodo

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.