use strict; use Carp qw(croak); use vars qw($AUTOLOAD); my %handler = ( hello => sub { print "Hello World\n" }, ); sub AUTOLOAD { (my $fn = $AUTOLOAD) =~ s/.*:://g; if (exists $handler{ $fn }) { goto &{ $handler{ $fn } } }; croak "Unknown method '$AUTOLOAD' called."; }; hello();