perl 创建包
发布时间:2020-12-15 23:39:41 所属栏目:大数据 来源:网络整理
导读:zjzc01:/root/big2# cat Employee.pm package Employee;use Data::Dumper;##创建正式雇员sub new_regular { my ($name,$age,$starting_position,$monthly_salary)=@_; my $employee = { "name" =$name,"age" =$age,"position" =$starting_position,"montly_s
zjzc01:/root/big2# cat Employee.pm package Employee; use Data::Dumper; ##创建正式雇员 sub new_regular { my ($name,$age,$starting_position,$monthly_salary)=@_; my $employee = { "name" =>$name,"age" =>$age,"position" =>$starting_position,"montly_salary" =>$monthly_salary,}; return $employee; ## 返回对象引用 }; zjzc01:/root/big2# perl a36.pl Employee.pm did not return a true value at a36.pl line 3. zjzc01:/root/big2# cat a36.pl unshift(@INC,"/root/big2"); require Employee; zjzc01:/root/big2# perl a36.pl Employee.pm did not return a true value at a36.pl line 3. zjzc01:/root/big2# cat a36.pl unshift(@INC,"/root/big2"); require Employee; use Data::Dumper; $var=Employee::new_regular(a,b,c); my $xx= Dumper($var); print $xx; print "n"; print $var->{name}; print "n"; zjzc01:/root/big2# perl a36.pl $VAR1 = { 'position' => 'c','name' => 'a','montly_salary' => undef,'age' => 'b' }; a (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |