sub burrito2 { my $self = shift; # use this form if you need the super class's method # to run before your overrides take place my $x = $self->SUPER::__foo("Charles"); # override some stuff return $x; }

1;

Tests

Code

perl -MTacoBell -le '$t=TacoBell->new();$t->iAmFoobar' Hello foobar.

perl -MTacoBell -le '$t=TacoBell->new();$t->__foo("Chuck")' Access to private method denied. at foobar.pm line 17. foobar::__foo('TacoBell=HASH(0x605998)', 'Chuck') called at -e line 1

perl -Mfoobar -le '$t=foobar->new();$t->iAmFoobar' Hello foobar.

perl -Mfoobar -le '$t=foobar->new();$t->__foo("Chuck")' Hello Chuck.

perl -MTacoBell -le '$t=TacoBell->new();$t->burrito()' Access to private method denied. at foobar.pm line 15. foobar::__foo('TacoBell=HASH(0x605998)', 'Charles') called at TacoBell.pm line 17 TacoBell::burrito('TacoBell=HASH(0x605998)') called at -e line 1

perl -MTacoBell -e '$t=TacoBell->new();$t->burrito2()' Access to private method denied. at foobar.pm line 15. foobar::__foo('TacoBell=HASH(0x605a70)', 'Charles') called at TacoBell.pm line 26 TacoBell::burrito2('TacoBell=HASH(0x605a70)') called at -e line 1