in reply to subroutine inside subroutine

You should avoid nested named routines. For starters, they aren't private so there's no benefit to doing so. You can also encounter subtle problems from compile-time capturing ("will not stay shared" warnings will indicate the possibility of such problems if you're using warnings).