[Chicago-talk] Shortening a module name

Jay Strauss me at heyjay.com
Mon Feb 20 09:46:27 PST 2006


I have a module:


When a user creates a:

my $tws = Finance::InteractiveBrokers::TWS->new();

is there a way I could provide a shortcut, in 
Finance::InteractiveBrokers::TWS, for the user to create a contract, without 
having to build a sub like

sub new_Contract {
    my $self = shift;

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 

I know I could do $tws->contract('new'), but that doesn't seem OO proper.


More information about the Chicago-talk mailing list