Archive for 2010 年 3 月 21 日
关于Perl的几点:多行注释,REF函数,类的初始化
0多行注释:
perl没有多行注释,可以用下面代替:
=pod
代码行;
.
.
.
代码行;
=cut
关于ref函数:
ref EXPR
ref Returns a non-empty string if EXPR is a reference, the empty
string otherwise. If EXPR is not specified, $_ will be used. The
value returned depends on the type of thing the reference is a
reference to. Builtin types include:
SCALAR
ARRAY
HASH
CODE
REF
GLOB
LVALUE
If the referenced object has been blessed into a package, then
that package name is returned instead. You can think of “ref” as
a “typeof” operator.
讲类的段落,比较明了:
Object Construction
All objects are references, but not all references are objects. A reference won’t work as an object unless its referent is specially marked to tell Perl what package it belongs to. The act of marking a referent with a package name–and therefore, its class, since a class is just a package–is known as blessing. You can think of the blessing as turning a reference into an object, although it’s more accurate to say that it turns the reference into an object reference.
(更多…)