Vsftp:/root/perl/17# cat Critter.pm package Critter; sub new { my $self = {}; my $invocant = shift; my $class = ref($invocant) || $invocant; my ($name)=@_; my $self = { "name" =>"luotuo", @_ # 覆盖以前的属性 }; bless $self, $class; # Use class name to bless() reference return $self; }; sub sum { $self=shift; my $a=shift; my $b=shift; return $a + $b; }; 1; Vsftp:/root/perl/17# cat a1.pl unshift(@INC,"/root/perl/17"); use Critter; use Data::Dumper; $ed = Critter->new('name'=>'poddinns'); print $ed->{name}; print " "; print $ed->sum(4,5); print " "; Vsftp:/root/perl/17# perl a1.pl poddinns 9