June 2001 Making a Module Back Slide 55 Forward

Still unknown functions

use vars qw ($AUTOLOAD);
sub AUTOLOAD
{
	my $name = $AUTOLOAD;
	$name =~ s/^.*:://;
	goto &Exporter::AUTOLOAD unless (exists $AUTOLOADABLE{$name});

	my $self = shift;
	if ($AUTOLOADABLE{$name} eq 'h') {
		return %{($self->{$name}	|| undef)};
	} elsif ($AUTOLOADABLE{$name} eq 's') {
		return $self->{$name}		|| undef;
	} else {
		return undef;
	}
}

  • Will call Exporter::AUTOLOAD for unknown methods (including DESTROY)
  • Have other options, including looking in @ISA


Copyright © 2001 R. Geoffrey Avery Back Contents Forward