## DOC: returns a function that does that and that. sub ff { my $myval=myfunc(); ... sub { g(++$myval) } } ... my $f = ff; ... my $x = $f->();