package ClientFactory; sub genericClient { my $client = new Client(); my $calculator = new InvoiceCalculator ($client); $client->setCalculator ($calculator); return ($client); } package main; my $client = ClientFactory::genericClient(); my $calculator = $client->getCalculator();