这是因为你使用了 OO 特性,就使得第一个参数成了对象或类的描述。这里的逻辑很简单,看不出使用 ->max 的理由。 直接使用标准 sub 就 ok 了,从而不必 shift 掉第一个 reference 或者类名。
2009/2/26 mark <[email protected]> > > #tt.pl > use strict; > use warnings; > use PM::MK1; > my ($zhu,$mark)=(1333,122222); > my $max=MK1->max($zhu,$mark); > print "3:MAX:$max\n"; > > #我的包文件MK1.pm > package MK1; > sub max{ > shift(@_); > my($temp1,$temp2)=...@_; > print "2:$temp1 ***$temp2\n"; > if($temp1 > $temp2){ > return $temp1; > }else{ > return $temp2; > } > } > > return 1; > > 如果我没用“shift(@_); ” ,$temp1=MK1; > 我不知道为什么? > > > --~--~---------~--~----~------------~-------~--~----~ 您收到此信息是由于您订阅了 Google 论坛“PerlChina Mongers 讨论组”论坛。 要在此论坛发帖,请发电子邮件到 [email protected] 要退订此论坛,请发邮件至 [email protected] 更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛 -~----------~----~----~----~------~----~------~--~---
