3.访问整个哈希
- $family_name{"fred"}
对 hash赋值会带来列表赋值的上下文,列表的元素应该是键值对
- %family_name
%family_name = ("foo",35,"bar",12.4); %family_name = qw/foo 35 bar 12.4/; %family_name = 用胖箭头; |
- @H_502_0@ %new_hash = %old_hash;
@H_502_0@ 4.哈希函数
- hash赋值直观的写法
- my %family_name = (
- "foo" => 35,
- "bar" => 12.4,
- );
@H_502_0@ # 到返回空列表时循环结束
- while (($key,$value)= each %hash) {
- print "$key => $value\n";
- }
@H_502_0@ # 返回真则键diao存在
- if (exists $hash{"diao"})
@H_502_0@ # 假如键不存在,它直接结束,不会给出任何提示信息。 @H_502_0@
- delete $hash{"diao"}