문제

Why do I get the values from "$n" and "$m" after deleting the respective symbol-table-entries?

#!/usr/bin/env perl
use warnings;
use 5.012;

package Foo;

our $n = 10;
our $m = 20;

delete $Foo::{'n'};
delete $Foo::{'m'};

say $n; # 10
say $m; # 20
도움이 되었습니까?

해결책

Because the symbol table is only used at compile time (or via symbolic reference). The glob that is the value of $Foo::{...} is referenced directly by the compiled code so the no-longer-present symbol table entry has no effect.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top