A Continental Perl Adventure
Day One
29 of 96 : [
PREV
] [
NEXT
]
Simple Autoload example extended
@funcs = qw{ red yellow blue };
sub red { ... }
sub yellow { ... }
sub blue { ... }
sub AUTOLOAD {
my ($package, $function) = ($AUTOLOAD =~ /(.*)::(.*)/);
my $correct = approximate_match($function, \@funcs);
if(defined &$correct) {
return &$correct(@_);
} else {
die "Function $function unknown; try [@funcs]\n";
}
}
now if you do
blug(...);
you'll call blue(...)
© 2003 Barbie
barbie@missbarbell.co.uk
Home
http://birmingham.pm.org/