Perl: “Variable will not stay shared”

后端 未结 4 1602
无人共我
无人共我 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 14:11

    If you want to minimize the amount of size passing parameters to subs, use Perl references. The drawback / feature is that the sub could change the referenced param contents.

    my $dom = someBigDOM;
    my $resultVar = doStuffWith(\$dom);
    
    
    sub doStuffWith {
       my $dom_reference = shift;
       my $dom_contents = $$dom_reference;
       #...
    }
    

提交回复
热议问题