#! /usr/bin/perl<br>use strict;<br>use warnings;<br><br>my $test = 0;<br>warn &#39;main: &#39;, \$test, &#39; &#39;, $test;<br><br>my $func1 = sub {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $test .= 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; warn &#39;func1: &#39;, \$test, &#39; &#39;, $test;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sub func2 {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $test .= 2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; warn &#39;func2: &#39;, \$test, &#39; &#39;, $test;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>};<br><br>$func1-&gt;();<br>func2();<br>$func1-&gt;();<br>func2();<br>$func1-&gt;();<br>
func2();<br>func2();<br>func2();<br>func2();<br>warn $test;<br><br>##################<br>main: SCALAR(0x182f478) 0 at 2.pl line 6.<br>func1: SCALAR(0x182f478) 01 at 2.pl line 10.<br>func2: SCALAR(0x18545b4) 2 at 2.pl line 13.<br>
func1: SCALAR(0x182f478) 011 at 2.pl line 10.<br>func2: SCALAR(0x18545c0) 22 at 2.pl line 13.<br>func1: SCALAR(0x182f478) 0111 at 2.pl line 10.<br>func2: SCALAR(0x18545b4) 222 at 2.pl line 13.<br>func2: SCALAR(0x18545c0) 2222 at 2.pl line 13.<br>
func2: SCALAR(0x18545b4) 22222 at 2.pl line 13.<br>func2: SCALAR(0x18545c0) 222222 at 2.pl line 13.<br>0111 at 2.pl line 26.<br><br><br>Что говорит нам о том, что $test в func2 никак не связана с $test во всей остальной программе<br>