in reply to 'state' variables and unit testing
We just use:
sub somefunc { our $Var //= do { say "Heavy calculations"; 42+($ARGV[0]||0); }; } [download]
Best of both.
- tye