sub recursive { our $state; ... if (...) { local $state = ~~~; recursive(); } ... }