G'day mr.nick,

It looks like you've resolved your posted question with ++choroba's help.

As you "do very, very little OOP in Perl", I thought I'd draw your attention to the parent pragma which is used to "Establish an ISA relationship with base classes at compile time".

Using this pragma, your code might look at little more straightforward written along these lines:

$ perl -Mstrict -Mwarnings -E ' package Event; sub new { my $class = shift; my $self = { EventType => "Windows 2003", @_ }; bless $self => ref $class || $class; } package Event08; use parent qw{-norequire Event}; sub new { shift->SUPER::new(EventType => "Windows 2008", @_); } package Security; use parent qw{-norequire Event}; sub new { shift->SUPER::new(EventLog => "Security", @_); } package Security08; use parent qw{-norequire Event08}; sub new { shift->SUPER::new(EventLog => "Security", @_); } package main; my $sec = Security::->new(some_attribute => "abc"); say "Class: ", ref $sec; say "EventType: ", $sec->{EventType}; say "EventLog: ", $sec->{EventLog}; say "Some attribute: ", $sec->{some_attribute}; my $sec08 = Security08::->new(some_attribute => "xyz"); say "Class: ", ref $sec08; say "EventType: ", $sec08->{EventType}; say "EventLog: ", $sec08->{EventLog}; say "Some attribute: ", $sec08->{some_attribute}; ' Class: Security EventType: Windows 2003 EventLog: Security Some attribute: abc Class: Security08 EventType: Windows 2008 EventLog: Security Some attribute: xyz

Notes:

-- Ken


In reply to Re: Can you help me understand this OO notation/issue? by kcott
in thread Can you help me understand this OO notation/issue? by mr.nick

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.