Created
July 14, 2011 04:07
-
-
Save preaction/1081918 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package Foo::Graph; | |
| sub new { | |
| my $proto = shift; | |
| my $class = ref($proto) || $proto; | |
| my $self = { | |
| template => undef, | |
| }; | |
| bless( $self, $class ); | |
| #my $template = shift || confess "missing template"; | |
| #$self->{template} = $template; | |
| $self->{warnings} = []; | |
| return $self; | |
| } | |
| sub foo() { | |
| return "abc123"; | |
| } | |
| # ====================================== | |
| package Foo::ImageGraph; | |
| use base qw( Foo::Graph ); | |
| sub new { | |
| my $proto = shift; | |
| my $class = ref($proto) || $proto; | |
| my $self = $class->SUPER::new(@_); | |
| bless( $self, $class ); | |
| return $self; | |
| } | |
| # ====================================== | |
| package Foo::TimeGraph; | |
| use base qw( Foo::ImageGraph ); | |
| sub new { | |
| my $proto = shift; | |
| my $class = ref($proto) || $proto; | |
| my $self = $class->SUPER::new(@_); | |
| bless( $self, $class ); | |
| return $self; | |
| } | |
| sub bar { | |
| my $self = shift; | |
| #print Dumper( our @ISA ); => Foo::ImageGraph | |
| print $self->foo(); | |
| } | |
| #============================== | |
| package main; | |
| my $obj = Foo::TimeGraph->new; | |
| $obj->bar; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment