Assuming code-tampering is not an issue, how about this:
in reply to Is modifying the symbol table to redefine subroutines evil?
Unfortunately, Murphy's laws will kick in if the caller decides to use a copy/clone of the $foo scalar, so don't do that.
my $foo; # Global, because this is the only visible (subroutine ref)
print qq[First call - do first processing here \n];
# First processing code goes here ...
# Now setup for subsequent calls ....
print qq[subsequent calls\n]
# Code for subsequent calls goes here
$foo->() for 0..5; # OK - so the subroutine call looks slightly weird
"Choose a job you like and you will never have to work a day of your life" - Confucius