Perl: “Variable will not stay shared”

后端 未结 4 1601
无人共我
无人共我 2021-02-12 13:16

I looked up a few answers dealing with this warning, but neither did they help me, nor do I truly understand what Perl is doing here at all. Here\'s what I WANT it to do:

<
4条回答
  •  你的背包
    2021-02-12 13:57

    Following http://www.foo.be/docs/perl/cookbook/ch10_17.htm , you should define a local GLOB as follows :

    local *innerSub = sub {
        ...
    } 
    #You can call this sub without ->
    innerSub( ... ) 
    

    Note that even if warning is displayed, the result stay the same as it should be expected : variables that are not defined in the inner sub are modified in the outer sub scope. I cannot see what this warning is about.

提交回复
热议问题