哈希元素赋值:
$hash{$some_key} = ‘something'
访问整个哈希:
%some_hash = (’a' , '0' , 'b' , '1' , 'c' , '3')
@any_array =%some_hash #哈希展开,获得所有哈希的键值对,乱序。
哈希赋值:
my %new_hash = %some_hash
my %new_hash2 = reverse %some_hash # 得到值-键 值-键 对
my %last_hash = (
'fred' => 'a' #胖箭头赋值
'tim' => 'b'
);
哈希函数:keys values each
my @k = keys %last_hash # fred tim
my @v = values %last_hash #a b
while ( ($key , $value) = each %last_hash) {
print ” “;
}
exist/delete 函数:
if (exist $books{”dino"}) {
}
delete $books{“dino”} #删除键值对