Skip to content

Instantly share code, notes, and snippets.

@foursixnine
Last active March 5, 2018 15:30
Show Gist options
  • Save foursixnine/bdd8477433340a59489eb69fb81d04f2 to your computer and use it in GitHub Desktop.
Save foursixnine/bdd8477433340a59489eb69fb81d04f2 to your computer and use it in GitHub Desktop.
Multiple inheritance: Baz uses Bar as a base, who uses Foo as a base.
package Baz;
use base "Bar";
1;
package Foo;
sub new {
my $class = shift;
return bless {}, $class;
}
sub exclaim {
$self = @_;
print "I can have such a thing?!\n";
}
1;
package Bar;
use base "Foo";
sub from_bar {
$self = @_;
"I come from Bar"
}
sub exclaim {
$self = @_;
print "I come from Bar\n";
$self->SUPER::exclaim();
}
1;
use Baz;
my $ob = Baz->new();
$ob->exclaim();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment