Monks,
Today I was examining a method in my codebase and I wanted to test changes to it, so I overloaded the method using the glob operator like so.
What's going on here? It seems that when sub foo() was redefined, calls to SUPER were passed to main. I dumped @ISA for both sub calls and it's unchanged.#!perl use strict; use warnings; use foo::bar; my $bar = foo::bar->new; $bar->foo; # prints "FOO!" *foo::bar::foo = sub { my $self = shift; $self->SUPER::foo; }; $bar->foo; # results in "Can't locate object method \"foo\" via packag +e \"main\" at foo.pl line 12 pacakge foo; use strict; use warnings; sub foo { print "FOO!"; } 1; package foo::bar; use strict; use warnings; use base 'foo'; sub new { my $class = shift; my $self = {}; bless $self, $class; return $self; } sub foo { my $self = shift; # Set some attributes on $self - not done in overloaded method $self->SUPER::foo; } 1;
In reply to SUPER lost in overloaded method by redhotpenguin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |