{ my $_cache; sub withLongComputation { $_cache //= ...; ... } sub clearCache { undef $_cache; } }