June 2001 Making a Module Back Slide 60 Forward

The actual function that would have existed

# my $self = shift;
  no strict 'refs';
  if ($AUTOLOADABLE{$name} eq 'h') {
    my $code = q{
                 sub {
                      my $self = shift;
                      my $val = $self->{METHODNAME};
                      return (($val) ? %{$val} : undef);
                     }
                };
    $code =~ s/METHODNAME/$name/g;

    *$name = eval $code;    
    goto &$name;
  }

  • Actually makes the method so AUTOLOAD will not be called again for the same method


Copyright © 2001 R. Geoffrey Avery Back Contents Forward