my %cache; while($foo < (exists $cache{$bar} ? $cache{$bar} : $cache{$bar} = &ReallyComplexFunction($bar))) { doStuff(); }