Perl using Hashes

来源:互联网 发布:js 正则 身份证号 编辑:程序博客网 时间:2024/06/05 08:28

初始化

%hash1 = (the, 200, of, 149);
%hash2 = ("the", 200, "of", 149);
%hash3 = (the => 200, of =>149);
%hash4 = ("the" => 200, "of" =>149);

%hash5 = (1..9)

存取

++$counts{ $word }

Functions

@indexes = keys %words;
@wordlist = values %words;
exists ($words{ $key })