标签:bsp ott key pre line ash hashmap code bottom
my @array = qw(aa bb cc dd);my @select = @array[1,3];print "@select\n";##输出bb dd123456
my %hash = ( "a" => 1, "b" => 2, "c" => 3, "d" => 4, );my @select = @hash{qw(a c)}; ## 提取key为‘a’‘c’对应的值print "@select\n";##输出为1 31234567891011
my %hash = ( "a" => 1, "b" => 2, "c" => 3, "d" => 4, );my %select = %hash{qw(a c)}; ##提取key为‘a’‘c’的hashmap {print "$_=> $select{$_}\n"} keys %select;##输出为:a=> 1c=> 3
perl切片(数组和哈希)二
原文地址:http://blog.51cto.com/346054/2063074