Several problems here. Some are just typos, I think. For
example you have "%keys %METHODS"; presumably you
just mean "keys %METHODS". Another is you have "*$methods"
where presumably you mean "$method".
But the main problem is that you need to set up your %METHODS
hash in the BEGIN block, so that it gets initialized *before* you
try to use it. Ie.:
my(%METHODS);
our @EXPORT;
BEGIN {
%METHODS = (
foo => 'bar',
bo => 'baz',
);
@EXPORT = keys %METHODS;
foreach my $method (keys %METHODS) {
no strict 'refs';
*$methods = sub {
return $METHODS{ $method };
};
}
}