in reply to Re: Perlish dice for gamers (oh, and importing autoloaded functions)
in thread Perlish dice for gamers (oh, and importing autoloaded functions)
hossman wrote:
Can anybody out there think of a way to genuinely create an entry the symbol table for a package that points to "AUTOLOAD" ?
I was in the middle of typing why this couldn't be done, when I talked myself into a way of trying it! What do you think of this?
sub import { no strict 'refs'; my $pkg = shift; for my $dice (@_) { if ($dice =~ /r(\d+)[Dd](\d+)/) { # my $meth = \sub { roll($1, $2); }; my $meth = \sub {"__PACKAGE__::$dice"}; *{$pkg . '::' . $dice} = $meth; } } @EXPORT_OK = @_; Smonk->export_to_level(1, $pkg, @_); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Perlish dice for gamers (oh, and importing autoloaded functions)
by hossman (Prior) on Sep 10, 2002 at 04:07 UTC | |
by Solo (Deacon) on Sep 10, 2002 at 13:31 UTC |