[Chicago-talk] Shortening a module name
José Castro
jac at natura.di.uminho.pt
Mon Feb 20 09:57:33 PST 2006
* Jay Strauss (me at heyjay.com) wrote:
> Hi,
>
> I have a module:
>
> Finance::InteractiveBrokers::TWS::com::ib::client::Contract
>
> When a user creates a:
>
> my $tws = Finance::InteractiveBrokers::TWS->new();
>
> is there a way I could provide a shortcut, in
Yes.
http://search.cpan.org/~ovid/aliased-0.20/
> Finance::InteractiveBrokers::TWS, for the user to create a contract, without
> having to build a sub like
>
> sub new_Contract {
> my $self = shift;
> return
> Finance::InteractiveBrokers::TWS::com::ib::client::Contract->new(@_);
> }
>
> within Finance::InteractiveBrokers::TWS?
>
> I was thinking something along the lines of:
>
> my $contract = $tws->contract->new();
>
> Maybe by employing AUTOLOAD, or some other means? I've been messing with
> AUTOLOAD but I can't get it to work. The above obviously wants the
> $tws->contract to return an object, that can be new'd, whereas I'd like to
> get "new" as a parameter to AUTOLOAD and I could do logic for the proper
> dispatch.
>
> I know I could do $tws->contract('new'), but that doesn't seem OO proper.
>
> Thanks
> Jay
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
--
Jose Alves de Castro <cog at cpan.org>
http://jose-castro.org/
More information about the Chicago-talk
mailing list