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 c…
1.XXX.pm 文件里面的第一行要是:package XXX: 2.要有构造函数 sub new,实现如下: sub new { my $class = shift; # Get the request class name my $self = {}; my ($name)=@_; my $self = { "name" =>$name }; bless $self, $class; # Use class name to bless() reference return $…