in reply to Re^2: Variable will not stay shared in subroutine
in thread Variable will not stay shared in subroutine

I found this thread when looking for explanation for this message. In my case the solution is using "our" instead of "my". As a side effect the variable is a global with limited visibility.
  • Comment on Re^3: Variable will not stay shared in subroutine

Replies are listed 'Best First'.
Re^4: Variable will not stay shared in subroutine
by choroba (Cardinal) on Feb 02, 2018 at 23:13 UTC
    You've just treated the symptoms, not the cause. In Perl, it makes no sense to define a named subroutine inside a named subroutine, as the nested subroutine is still globally visible.

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re^4: Variable will not stay shared in subroutine
by LanX (Saint) on Feb 03, 2018 at 11:37 UTC
    If you really need a nested subroutine for the current scope only, then better use an anonymous one, like already described here by tilly.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Wikisyntax for the Monastery