Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- package Foo;
- use strict;
- use warnings;
- sub new {
- my $class = shift;
- my %self = map { $_ } @_;
- bless \%self, $class;
- }
- sub what {
- my $self = shift;
- return "foo";
- }
- }
- {
- package Bar;
- use strict;
- use warnings;
- use base qw/ Foo /;
- my $obj = Foo->new();
- # how do i get this sub to overwrite the what() in Foo?
- sub what {
- my $self = shift;
- return "bar";
- }
- print $obj->what;
- }
Add Comment
Please, Sign In to add comment