in reply to can('SUPER::defaults')

$self->can('SUPER::defaults') is looking for the method 'defaults' in Object.pm's SUPER class, but it does not have a SUPER class (it IS the SUPER-most class); this is why '$self->can()' fails.

Class Hiearchy:
Object
Mover
Player
main

Replies are listed 'Best First'.
Re: Re: can('SUPER::defaults')
by chromatic (Archbishop) on Oct 23, 2001 at 23:14 UTC
    I disagree:
    #!/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.