All pastes #2054269 Raw Edit

one file oo in perl

public text v1 · immutable
#2054269 ·published 2011-05-05 16:56 UTC
rendered paste body
use strict;
use warnings;

package Foo;

# doesn't have a new(), i'm just going to bless 
# stuff in manually

sub bark {
    print "i'm in foo, and i can bark.  woof!\n";
}

package Bar;
use Data::Dumper;

sub bark {
    my $self = shift;
    print "here's what my self object looks like:". Dumper($self);
    print "and I can also say woof.  Woof!\n";
}

package Baz;
@Baz::ISA=qw/Bar/;

package main;

my $sally = bless {}, 'Foo';

$bob->bark;

my $bob = bless [], 'Bar';

$sally->bark;

my $charles = bless {some=>'totally', random=>'hash'}, 'Baz';

$charles->bark;