rub*_*buc 11 perl lexical-scope
Perl中的本地变量分配的内存位置有多长(对于数组,散列和标量)?例如:
sub routine
{
my $foo = "bar";
return \$foo;
}
Run Code Online (Sandbox Code Playgroud)
"bar"函数返回后,你还可以访问内存中的字符串吗?它会持续多长时间,它是否类似于C中的静态变量或更像是从堆中声明的变量?
基本上,这在这种情况下是否有意义?
$ref = routine()
print ${$ref};
Run Code Online (Sandbox Code Playgroud)