Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Friday January 07, 2005
11:16 AM

"aliased" on the CPAN

[ #22615 ]

aliased is now on the CPAN. The syntax is cleaned up from what I originally had.

# implicit alias:
use aliased 'Some::Long::Module::Name';

# explicit alias:
use aliased 'Some::Long::Module::Name' => 'Name';

# import lists require using explicit aliasing:
use aliased 'Some::Long::Module::Name'=> 'Name, qw/foo bar baz/;

# and all of the above allow you to call class methods
# on the alias:
my $new_name = Name->new;
my $old_name = Name->search($id); # etc.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Why would I use your module instead of the namespace module? It seems like your module solves a sub-set of the problem solved by the namespace module. I read your docs but they didn't seem to answer the question. Maybe I missed something...

    -sam

    • First, if you just want the last part of the class name, aliased has the simpler syntax:

      use aliased "Really::Long::Class::Name::For::Customer";
      my $cust = Customer->new;

      # versus

      use namespace Customer => "Really::Long::Class::Name::For::Customer";
      my $cust = Customer->new;

      Second, compare the implementations. I am just exporting a single subroutine. namespace jumps through a lot of weird hoops, diddles the aliased @ISA array, and has rather coplicated code. Further, it will die if the target n

      • Yes, I think you should document it, particularly since you mention a good reason that I would use namespace: it works for :: in addition to ->. I find the point about tests to be particularly compelling, personally.

        -sam

        • I was mistaken. namespace also does not allow function calls. In trying this with my test suite, I have this:

          #!/usr/local/bin/perl
          use warnings;
          use strict;
          use lib 't/lib';

          use namespace 'This::Name' => 'Really::Long::Module::Name';

          use Data::Dumper;
          print Dumper( This::Name::new('This::Name') );

          It says that This::Name::new is an undefined subroutine. But, it turns out the problem is worse than that!

          #!/usr/local/bin/perl
          use warnings;
          use strict;
          use lib 't/lib';

          use namespace 'This::Name' => 'Real