sub new { my ($class, %args) = @_; my $handlers; # change all nice_perlish_names into nicePerlishNames %args= _normalize_args( %args); # check options unless( $args{MoreOptions}) { foreach my $arg (keys %args) { carp "invalid option $arg" unless $valid_option{$arg}; } } # a twig is really an XML::Parser # my $self= XML::Parser->new(%args); my $self; $self= XML::Parser->new(%args); bless $self, $class; #... yadda yadda
and indeed it does inherit from XML::Parser @ISA = qw(XML::Parser);
This seems to be a highly complex module also playing with UNIVERSAL so I don't feel competent to comment.
I'd say the new() method is inherited but overridden, and instead of using SUPER::new() an explicit XML::Parser->new() is used to initialize a parent object and alter it.
Never used SUPER or Java so take it with a grain of salt, others with more expertise will comment soon on the basis of this post.
I hope it's obvious that analyzing XML::Twig is not the best way to start learning Perl's OOP. :)
In reply to Re^3: OOP and derived classes
by LanX
in thread OOP and derived classes
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |