-
慕雪6442864
1234567891011121314可以用引用引用也可以转成string@m = ('1', '2', '3');@n = ('4', '5', '6');$H{\@m} = 1;$H{\@n} = 1;$sm = join('-', @m);$sn = join('-', @n);$S{$sm} = 1;$S{$sn} = 1;print key_exists(1, 2, 3);sub key_exists { my $str = join('-', @_); return exists $S{$str}?1:0;}
-
红糖糍粑
use strict;use warnings;my %hash=(a=>{1=>10,2=>20},b=>{3=>30,4=>40});foreach my $key1 (keys(%hash)){print("\$hash{$key1} has keys:".join(',',keys(%{$hash{$key1}})),"\n");}
-
海绵宝宝撒
你可以参考下面的代码, 测试过了.1234567891011121314use strict;my @array = ("aaa,vbbbb","cccc,ddddd","eeeee,xxxxx");my %hash_output;#数组每个元素按","分开,并按HASH表存储for(@array){ my ($key,$value) = split ','; $hash_output{$key} = $value;}#检查hash表的最终值for(keys %hash_output){ print "[key] $_ ==> [value] $hash_output{$_}\r\n";}