
Laurent_R
Veteran
/ Moderator
Apr 15, 2014, 2:15 AM
Post #4 of 4
(15555 views)
|
Re: [Iconx] Multi-dimensional Hashes and value searches
[In reply to]
|
Can't Post
|
|
It seems that you don't have a simple hash, but a hash of hashes (HoH). If you are unsure on how to use this type of structure, you probably need to read the perldsc document: http://perldoc.perl.org/perldsc.html. Your need is not entirely clear to me, but you could try something like this:
use strict; use warnings; my %outerhash = ( one => { "status" => "V", "filepath" => "../records/active/250498.user73a", "acctname" => "user73a", "type" => "Prod", "uid" => "3001", }, two => { "status" => "X", "filepath" => "../records/active/250498.user73a", "acctname" => "user73a", "type" => "Prod", "uid" => "3002", }, three => { "status" => "V", "filepath" => "../records/active/250498.user73a", "acctname" => "user73a", "type" => "Prod", "uid" => "3003", }, ); foreach my $hashref (values %outerhash) { next unless defined $hashref->{status}; next if $hashref->{status} ne "V"; print "\n"; foreach my $key (keys %{$hashref}) { print "$key => $hashref->{$key}\n"; } } This will print the following:
acctname => user73a uid => 3003 status => V type => Prod filepath => ../records/active/250498.user73a acctname => user73a uid => 3001 status => V type => Prod filepath => ../records/active/250498.user73a I hope this is more or less what you were looking for.
|