That's a problem with Perl's absolute minimal OO. People have recognized this, and several solutions are available. For instance, using inside-out objects, you can do this with minimal code changes:
package FunnyEmail; use base Email::Simple; use Hash::Util::FieldHash 'fieldhash'; ### Add this fieldhash my %JOKE; ### Add this sub new{ my $class = shift; my $text = shift; # assume this gets passed my $self=Email::Simple->new($text); $JOKE{$self} = undef; ### Change this bless $self,$class; return $self; }
Now your 'JOKE' attribute is in a lexical variable, and not accessable outside of the lexical scope. So, it would not clash with whatever Email::Simple is using, nor will it clash with anything a subclass of FunnyEmail would be doing.

In reply to Re: avoiding overwriting variables in an inherited class by JavaFan
in thread avoiding overwriting variables in an inherited class by whatnext156

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.