in reply to Re: Re: use Very::Long::Module::Name as Foo;
in thread use Very::Long::Module::Name as Foo;
Now if you want parametrized uses, consider the following (untested):
This can now be used (assuming no bugs...) as follows:package load; use Carp; use strict; sub as { my $pkg = shift; # Set the alias. $_[0] = $pkg; # load the module eval "require $pkg"; die $@ if $@; # import it? shift; if (@_) { unshift @_, $pkg; my $import = $pkg->can("import") or croak("No import available to use"); goto &$import; } } 1;
If you prefer a constant approach, that isn't hard to do either.use load; Very::Long::Module->load::as my $short => qw(foo bar baz);
In any case the difference in ease of usage between these solutions and a source filter is pretty minor. The difference in potential problems is pretty large. (Note that I am steering towards solutions where you can create any aliases for yourself without trampling on any potential global namespace. That is both deliberate and, I feel, important.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: use Very::Long::Module::Name as Foo;
by liz (Monsignor) on Oct 14, 2003 at 18:06 UTC | |
by tilly (Archbishop) on Oct 15, 2003 at 03:04 UTC | |
|
Re4: use Very::Long::Module::Name as Foo;
by dragonchild (Archbishop) on Oct 14, 2003 at 17:48 UTC | |
by liz (Monsignor) on Oct 14, 2003 at 18:18 UTC | |
by tilly (Archbishop) on Oct 15, 2003 at 02:48 UTC |