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");
}
可以用引用引用也可以转成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;
}