use Memoize; memoize('dbi'); sub dbi { DBI->connect(yadda, yadda); }