Class->method(@arg)===================Class::method('Class',@args);
Instance->method(@arg)=================Class::method(Instance,@arg);
第一个参数是instace
bless的解释可参见
@L_502_0@
bless in perldoc
http://perldoc.perl.org/functions/bless.html
my $scalar;
my @array;
my %hash;
my $instance = /$scalar(/@array,%hash)
bless $instance $class;
ref in perldoc
http://perldoc.perl.org/functions/ref.html
ref EXPR
判断变量是否是reference
ref $either ? $$either #this is a reference
: "not ref"; #this is not a ref
如果EXPR是ref,返回一个非空字符串,反之返回空字符串。返回值依赖ref引用的类型。内嵌类型包括:
- SCALAR
- ARRAY
- HASH
- CODE
- REF
- GLOB
- LVALUE
- FORMAT
- IO
- VSTRING
- Regexp
my $num = 0;
my $scaref = /$num;
if (ref $scaref eq "SCALAR") { print "this is a scalar reference./n";}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。