in reply to Re: Best/possible ways to dynamically use modules
in thread Best/possible ways to dynamically use modules
and now you can issue many calls to the lazy_use routine and it will parse once and import once. In fact this routine could be exported to other namespaces and should work correctly.{ my %is_imported; sub lazy_use { my ($class, @args) = @_; unless ($is_imported{"$class @args"}++) { my $file = $class; $file =~ s-::-/-g; $file .= ".pm"; require $file; my $importer = UNIVERSAL::can($class, "import"); goto &$importer if defined $importer; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re (tilly) 2: Best/possible ways to dynamically use modules
by perrin (Chancellor) on Dec 18, 2001 at 21:43 UTC | |
by tilly (Archbishop) on Dec 18, 2001 at 21:52 UTC |