All pastes #2054271 Raw Edit

one file oo in perl

public text v1 · immutable
#2054271 ·published 2011-05-05 17:00 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;
our @ISA=qw/Bar/;

package main;


my $bob = bless [], 'Bar';
$bob->bark;

my $sally = bless {}, 'Foo';
$sally->bark;

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

$charles->bark;