我在主文件的某处定义了一个简单的哈希表
our %translations = (
"phrase 1" => "translation 1",
# ... and so on
);
在另一个文件中,我想添加更多的翻译。也就是说,我想要做这样的事情:
push our %translations, (
"phrase N" => "blah-blah",
# ....
"phrase M" => "something",
);
当然这段代码不会起作用:
push
不能与哈希一起使用。所以我的问题是:有什么简单而优雅的方法将值的哈希插入到现有的哈希中?我不想求助于...
$translations{"phrase N"} = "blah-blah";
# ....
$translations{"phrase M"} = "something";
由于在Perl中,您应该能够在代码中减少重复...
%translations
时这样做。 - plusplus