Slash Boxes
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

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • use class 'My::Company::Namespace::Customer';
    use class 'My::Company::Namespace::Preferred::Customer', as => 'Preferred';
    my $cust = Customer->new;
    my $pref = Preferred->new;
    So... what would it do if you had not used 'as => 'Preferred' in the second instance?

    It looks like it is "aliasing" the module name (the last part) but that is the same as the previous module... so would it re-alias Customer?

    And... does it alias all modules that are used after calling it? I think I'd really, really hate that part... I'd want to be able to say "only alias what I tell you to alias".

    Kinda ugly (just thrown out as a starting block) but how about:
    use class ('My::Company::Namespace::Preferred::Customer', as => 'Preferred');
    or even:
    use class;
    my $alias = new class;
    $alias->add('My::Company::Namespace::Preferred::Customer', 'Preferred');
    ... later (if desired/needed)...
    $alias->remove('My::Company::Namespace::Preferred::Custome r');
    Just some thoughts... (and I have no idea where the space before the 'r' in customer is coming from)
    • It only aliases what you tell it to alias, so no worries there. Also, the entire point of this is to keep things really, really simple. Dirt simple. Making it all OO defeats that. All this module really does (mostly) is to use the package in question and then insert a sub into your namespace that returns the name of the module.