【发布时间】:2012-09-06 12:43:36
【问题描述】:
我在网上找不到这个问题的答案。
使用 Dancer 和 Template 工具包,我有一个哈希数组,我想将其打印到我的 web 应用程序的表格中。 这就是我将数据结构发送到模板的方式:
template "find_ip_results2", {
user => \@user,
};
迭代此结构并访问每个键值对的正确 foreach 语法是什么?
【问题讨论】:
-
@user看起来像什么?元素是hashrefs吗?你展示它的方式,这是一个数组的哈希,而不是一个哈希数组。 -
数组看起来像这样: $VAR1 = { 'communities' => 'bar', 'priority' => ' 3', 'policyName' => 'TATA', }; $VAR2 = { 'communities' => 'baz', 'priority' => '1', 'policyName' => 'Google', }; $VAR3 = { 'communities' => 'foo', 'priority' => '4', 'policyName' => 'Peering', };
标签: perl iteration template-toolkit dancer