in reply to Re: Re: Whats wrong with symbol refs here?
in thread Whats wrong with symbol refs here?

What do you mean 'just creating real methods once'?? AutoLoader can create the methods once (during the first call) then you can goto the method (this is considered a 'good' goto). I'm also not saying this is better than your way, the only advantage to this way is that the method never gets created if its never called.
  • Comment on Re: Re: Re: Whats wrong with symbol refs here?

Replies are listed 'Best First'.
Re: Re: Re: Re: Whats wrong with symbol refs here?
by gellyfish (Monsignor) on Feb 05, 2002 at 11:01 UTC

    This is what I was referring to in my other writeup in this thread

    A real life example cut and paste from a production module :

    sub AUTOLOAD { my ( $self, $arg ) = @_; no strict 'refs'; (my $method = $AUTOLOAD ) =~ s/^.*:://; if ( exists $self->{_data}->{$method} ) { *{$AUTOLOAD} = sub { my ( $self, $arg ) = @_; if ( defined $arg ) { $self->{_data}->{$method} = $arg; } return $self->{_data}->{$method}; }; } else { croak qq%Can't locate object method $method via package % . __PA +CKAGE__ ; } goto &{$AUTOLOAD}; }

    /J\