[root@wx03 test]# cat x1.pm package x1; use Data::Dumper; sub new { my $self ={}; my $invocant = shift; my $class = ref($invocant) || $invocant; my ($name,$age,$starting_position,$monthly_salary)=@_; my $self = { "name" =>$name, "age" =>$age }; bless($self, $class); # 给予对象性质 return $self; }; my $a1='31dadada'; $a2='afdafsf21414dfsf'; sub sum_var { my ($self, $var1, # Name or IP number of host to ping $var2, # Seconds after which ping times out ) = @_; my $var3= $var1 + $var2; return $var3; } 1; [root@wx03 test]# perl a1.pl --------------------. afdafsf21414dfsf[root@wx03 test]#