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

后端 未结 4 1945
夕颜
夕颜 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:42

    This error can also happen if you've accidentally re-declared shared variables in the main thread of a script,

    `

    use vars qw(%types  %colors); 
    
    my %types = (...);    # bad
    %colors = (...);   # good
    

    `

提交回复
热议问题