Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: use Very::Long::Module::Name as Foo;

by Abigail-II (Bishop)
on Oct 14, 2003 at 14:40 UTC ( #299125=note: print w/replies, xml ) Need Help??

in reply to use Very::Long::Module::Name as Foo;

Here's a different way, also using a '', but no source filters. Usage:
use as Name => "Very::Long::Class::Name", args ...;
And this is the code:
package as; use strict; use warnings; sub import { my $class = shift; die "Usage: 'use as Name => Very::Long::Class::Name [args...]'" unless @_ >= 2; my $caller = caller (); my ($short, $long) = splice @_ => 0, 2; no strict 'refs'; @{"${short}::ISA"} = $long; eval <<" --"; package $caller; require $long; $short -> import (\@_) if $short -> can ("import"); -- die $@ if $@; } 1;

This follows a similar syntax as 'use if CONDITION, MODULE => ARGS'.


Replies are listed 'Best First'.
Re: Re: use Very::Long::Module::Name as Foo;
by liz (Monsignor) on Oct 14, 2003 at 15:33 UTC
    This is essentially the same API as Package::Alias, although different under the hood.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://299125]
usemodperl laughs, at you
usemodperl can see the monastery has become a rehab for children of the serpent :-)
usemodperl can't figure out how to get to comply with HTTP standards :-( HTTPS only!? Breaks older HTTP::Tiny...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2018-06-24 09:13 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.