in reply to Why doesn't @EXPORT = (keys %METHODS) work?
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 }; }; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (tilly) 2 (no begin): Why doesn't @EXPORT = (keys %METHODS) work?
by tilly (Archbishop) on Mar 17, 2001 at 18:27 UTC | |
|
Re: Re: Why doesn't @EXPORT = (keys %METHODS) work?
by dws (Chancellor) on Mar 15, 2001 at 06:41 UTC |