#1 遍历二维哈希+宇宙飞船符
foreach my $key1 (keys %hash){
my $hash2 = $hash{$key1};
foreach my $key2 (sort{$hash2->{$b}<=>$hash2->{$a}} keys %$hash2){
print $key1.”\t”.$key2.”\t”.$hash2->{$key2}.”\n”;
}
}
#2 控制输出小数点位数
my $var=123.454789;
$var=sprintf "%.2f",$var;
print $var."\n";
#3 子函数传参
my @alt_deps=split(/\,/,$_[0]);
网友评论