in reply to goto and AUTOLOADed methods

BTW, if you alias $_[0] with something nice like $self, you might as well use it:
sub AUTOLOAD { my $self = $_[0]; my $m = something_clever_returning_method_name(); my $sub = $self->can($m) || $self->can("AUTOLOAD"); die "Can't call $m on $self" unless defined($sub); goto &$sub; }
Though your die stringify's the object, which might look weird to some.

Replies are listed 'Best First'.
Re: Re: goto and AUTOLOADed methods
by Anonymous Monk on Aug 01, 2003 at 13:24 UTC
    Except that you're not aliasing anything ;) You're making a copy of $_[0]. If you modify $self, the variable aliased by $_[0] will not be modified.
    local $\="\n"; my $roy = 4; print $roy; print asdf($roy); print $roy; sub asdf { my $self = $_[0]; $_[0] = 66; $self = 0; return "yoda"; } __END__ 4 yoda 66
    Isn't perl fun ;)