它似乎filehandle
并format
没有任何前缀,所以我无法通过%{*spud}
.
有什么我想念的吗?
更新
如何访问format
?为什么$fd=*STDOUT
和$fd=\*STDOUT
两者都有效?
更新2
代码:
package Foo;
our $spud = 'a scalar';
our @spud = 'an array';
our %spud = (a => 'hash');
sub spud {}
format spud =
.
open 'spud', $0;
my $stash = \%Foo::;
my $name = 'spud';
my $glob = $$stash{$name};
for my $type (qw(SCALAR ARRAY HASH CODE IO FORMAT)) {
#this works
#print *$glob{$type}, $/;
#this doesn't work,only output one row of scalar
print *{$FOO::{spud}}{$type}, $/;
}
输出:
[root@perl]# perl tb
SCALAR(0xa4dcf30)
[root@perl]#