my $iold = sub { for my $i ( 1 .. $foo ) { if( bar($i) ) { return($i); } } }->(); # calls this anonymous sub (setting $iold)