为什么我从来没有见过这样的例子,你声明了哈希,然后把它放在另一个哈希中?
my %hash1={};
$hash1{'key1'}='1-111';
$hash1{'key2'}='1-222';
$hash1{'key3'}='1-333';
my %hash2={};
$hash2{'key1'}='2-111';
$hash2{'key2'}='2-222';
$hash2{'key3'}='2-333';
my %main_hash1={%hash1, %hash2};
我只见过这样的例子,他们将哈希放在哈希中,而不是哈希的变量:
my %main_hash2=( 'hash1' => {
'key1' => '1-111',
'key2' => '1-222',
'key3' => '1-333'
},
'hash2' => {
'key1' => '2-111',
'key2' => '2-222',
'key3' => '2-333'
}
);
(也与数组类似)