testemployee.pm
来自「perl learn perl by examples」· PM 代码 · 共 24 行
PM
24 行
use Employee;
use Benchmark;
package HashEmp;
sub new {
bless {name => 'ram', age => 23};
}
sub age {
$_[0]->{age};
}
package main;
$o = Employee->new(name => "ram", age => 32);
$o1 = HashEmp->new();
print $o->age, " ", $o1->{age},"\n";
# Measure speed of accessors for objects built using ObjectTemplate
# and an ordinary hash
timethese (100000,
{"Employee", '$x = $o->age',
"HashEmp" , '$x = $o1->age'
}
);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?