#!/usr/bin/perl -w
use strict;
package Obj;
sub new {
bless({}, $_[0]);
}
sub can {
my $self = shift;
warn "Called can in Obj.n";
$self->SUPER::can(@_);
}
package main;
my $o = Obj->new();
print $o->can('new'), "\n", UNIVERSAL::can($o, 'new'), "\n";
And just to be dangerous (it's cheaper than a motorcycle):
package UNIVERSAL;
sub new {
bless({}, $_[0]);
}
sub loop {
my $self = shift;
$self->SUPER::loop();
}
package main;
Universal->new->loop();
Try to catch this before it eats up your memory. |