Think about Loose Coupling | |
PerlMonks |
Can you help me understand this OO notation/issue?by mr.nick (Chaplain) |
on Sep 06, 2013 at 14:30 UTC ( [id://1052721]=perlquestion: print w/replies, xml ) | Need Help?? |
mr.nick has asked for the wisdom of the Perl Monks concerning the following question:
While I've been programming in Perl forever it seems, I do very, very little OOP in Perl so I'm a bit confused by this code I was shown recently. I'm hoping you folks might be able to divine why it would be done this way and finally, why the issue I'm seeing is occurring.
Firstly, there are two modules named AuditLogReview_Event.pm and AuditLogReview_Event08.pm. This is the first:
My first question is: what's the purpose of @ISA = qw(Event); @PARENT::ISA = @ISA? To me, that seems that it would make each class a subclass of the other. Why do that? For my second issue I need to show you the rest of the code, AuditLogReview_Event08.pm:
And finally, the test script, AuditTest.pl:
Now, the thing is, as written when it runs it produces the following: C:\Users\A209624\Desktop>perl AuditTest.pl Processing Windows 2008 Security event. Processing Windows 2008 Security event. Putting some debugging in there, I see that the Security->new() call goes to the right place, but when it does it's $class->PARENT::new(@_)it's hitting Event08 instead of Event. Why? I was able to get the behavior I wanted by changing the my $self = $class->PARENT::new(@_) in each package to
But I'm still unsure why the first way didn't work correctly. Thanks! mr.nick ...
Back to
Seekers of Perl Wisdom
|
|