符号表:删除条目
为什么在删除相应的符号表条目后,我会从“$n”和“$m”中获取值?
#!/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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为符号表仅在编译时使用(或通过符号引用)。作为
$Foo::{...}
值的 glob 由编译后的代码直接引用,因此不再存在的符号表条目不起作用。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.