包的子函数的参数
package Way::Hello sub new{ getClass(); #不会获得包名 Way::Hello->getClass(); #返回包名 } sub getClass{ my($class) = @_; return $class }
循环 哈希的两种方法
foreach $a (%hash){ print $a."=>".$hash{$a}; } while(($k,$v) = each(%hash)){ print $k,"=>",$v; }
获得已安装的模块
#/usr/bin/perl use strict; use warnings; use ExtUtils::Installed; my $inst = ExtUtils::Installed->new(); print join "\n",$inst->modules();