以下是我的哈希。我不想在值部分重复密钥(city
& country
)。
%sql_cache = (
city => "select * from city where id=106",
country => "select * from country where code='IND'",
);
是否有任何内置变量可以在Perl中实现?
答案 0 :(得分:3)
怎么样?
my %sql_cache = (
city => "select * from %s where id=106",
country => "select * from %s where code='IND'",
);
# use it
printf "$sql_cache{$_}\n", $_ for keys %sql_cache;