Typeglob 在文档中定义为 "
Perl uses an internal type called a typeglob to hold an entire symbol table entry."
如果定义了 $a, @a, %a
那么 *a 里就保存了以上三个变量地址 (\$a, \@a, \%a)
-
[myang@mnsdev13:~/demo]$ cat alias.pl
-
#!/usr/local/bin/perl5
-
-
-
$colors = "rainbow";
-
@colors = ("red", "green", "yellow");
-
-
-
&printit(*colors);
-
print $colors[0];
-
-
-
sub printit {
-
local(*whichone) = @_;
-
print *whichone, "\n";
-
print $whichone, "\n";
-
print $whichone[0], "\n";
-
-
-
$whichone = "hello world";
-
$whichone[0] = "BLUE";
-
}
输出结果:
-
[myang@mnsdev13:~/demo]$ alias.pl
-
*main::colors
-
rainbow
-
red
-
BLUE
阅读(650) | 评论(0) | 转发(0) |