as - load OO module under another name
This documentation describes version 0.13.
use as; # activate 'use' magic use Very::Long::Module::Name as => 'Foo'; use Other::Long::Module::Name qw(parameters being passed), as => 'Bar'; my $foo = Foo->new; # blessed as Very::Long::Module::Name my $bar = Bar->new; # blessed as Other::Long::Module::Name
Sometimes you get sick of having to use long module names. This module allows you to load a module and have it be aliased to another name.
Originaly Inspired by bart's response (http://www.perlmonks.org/index.pl?node_id=299082) to a thread about long module names on Perl Monks.
This module injects its own handling of require so that it can intercept any "as module" parameters. If found, it will alias the stash of the original module with the name to be aliased.
require
Any objects blessed with the aliased class name, will actually return the original module's name as the classed it has been blessed with. You could consider this as either a bug or a feature.
If there is an import class method available for the module being aliased, then this will only be called if any parameters (others than "as modulename") have been specified. This behaviour is based on the fact that this is the most likely wanted behaviour for object oriented modules, which rarely require an import method anyway.
warnings::register (any)
Elizabeth Mattijsen, <liz@dijkmat.nl>.
maintained by LNATION, <thisusedtobeanemail@gmail.com>
Please report bugs to <perlbugs@dijkmat.nl>.
Copyright (c) 2003, 2004, 2005, 2006, 2009, 2012 Elizabeth Mattijsen <liz@dijkmat.nl>. 2021 LNATION <thisusedtobeanemail@gmail.com> All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install as, copy and paste the appropriate command in to your terminal.
cpanm
cpanm as
CPAN shell
perl -MCPAN -e shell install as
For more information on module installation, please visit the detailed CPAN module installation guide.