2012年4月22日星期日

Programming Perl 4th : Chapter 6 - Chapter 8

Encode::Locale 识别本地编码

最烦的就是这种传参潜规则了
&foo; # foo() gets current args, like foo(@_), but faster!
foo; # like foo() if sub foo predeclared, else bareword "foo"

state不能用于 %hash,但可用于 $hashref

函数属性有两种,lvalue和method,可以用 sub somefunction : method {} 声明

左值函数的返回值能够被直接被赋值
my $val;
sub canmod : lvalue {
$val;
}
sub nomod {
$val;
}
canmod() = 5;
nomod() = 5;
# Assigns to $val.
# ERROR

软链接是解引用时用到的变量名称,可以用 use strict "refs"; 关闭
${identifier}; # Same as $identifier.
${"identifier"}; # Also $identifier, but a symbolic reference.
注意:软链接涉及symbol table,因此仅对包变量生效,对词法变量无效。

Tie::RefHash 支持将HASHREF做索引

没有评论:

发表评论