我有一个数组和哈希的哈希,如下所示:
$VAR1 = \{
'abc' => {
'def' => 'WorkSet',
'products' => [
{
'prodtype' => 'Dell',
'product' => 'Powerconnect-5600'
},
{
'prodtype' => 'Dell',
'product' => 'R-720'
},
{
'prodtype' => 'Dell',
'product' => 'R-920'
}
]
},
'123' => {
'456' => 'WorkSet',
'products' => [
{
'prodtype' => 'Dell',
'product' => '210'
},
{
'prodtype' => 'Dell',
'product' => 'TZ-200'
},
{
'prodtype' => 'Dell',
'product' => 'TZ-200'
},
]
}
}
我想要这样:
Branch: Workset
Build Number: abc
product : Dell producttype : PowerConnect-5600
product : Dell producttypr : R-720
product : Dell producttype : R-920
哈希值 123 也应该相同。
我知道单独遵守上述哈希值,但发现很难在循环中完成。
请给我你的指导。
仅供参考,我已经使用 Data:Dumper perl 模块列出了上述哈希值。
This is what I thought and tried but not getting the required answer in loops:
my @unique = uniq @version;
foreach $version(@ unique){
my $i=0;
print "$list->{$version}{branch}\n";
print "$list->{$version}->{products}->[$i]->{product}\n";
$i=$i+1;
} where @unique = qw (abc,123)