“Variable $foo will not stay shared” Warning/Error in Perl While Calling Subroutine

后端 未结 4 1948
夕颜
夕颜 2020-12-16 12:03

Update3: If you like this posting please don\'t upvote me but upvote the genius answer by DVK below.

I have the following subroutines:<

4条回答
  •  不思量自难忘°
    2020-12-16 12:55

    When getting a diagnostic message from perl, it's usually a good idea to check out perldiag to find out what it means. That manpage also happens to cover the warning you're getting.

    Basically, named subroutines don't nest in the way you were expecting them to. Solutions include using anonymous inner subroutines, not nesting named subroutines and just passing state on between them explicitly, or using something like mysubs from CPAN.

提交回复
热议问题