Perl for Newbies - Part 3 - Modules and ObjectsObjects in PerlMaking Your Own ObjectsObject InheritanceCalling Overridden Methods of Base Classes Calling Overridden Methods of Base Classes

It is possible to explicitly call the method of a base class even if it was overridden by another method in the derived class. To do that use the SUPER:: prefix before the method name.

Here is a rewrite of the Bar class, this time with assign_name retaining its name.

package Bar2;

use strict;
use warnings;

use vars qw(@ISA);

use Foo;


sub assign_name
    my $self = shift;

    my $name = shift;

    # Call the method of the base class
    my $ret = $self->SUPER::assign_name($name);
    if (! $ret)

    return $ret;

sub get_num_times_assigned
    my $self = shift;

        (exists($self->{'num_times'}) ?
            $self->{'num_times'} :


Written by Shlomi Fish