in reply to accessing data in hash

A slight variation on 2teez(++) , since you want to do comparisons after finding the item:
my ($item) = grep { $_->{ID} == 32 } @{ $hash->{data} }; # Assumes ID + is unique die "No item had ID 32" unless $item; # Now compare Item's state.. if ($item->{State} eq "Stopped"){ print "Oh - I did not expect this\n"; }
FYI - you have a hash containing an array of hashes.

        What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?
              -Larry Wall, 1992

Replies are listed 'Best First'.
Re^2: MIS-PARENTED: PLEASE REAP: accessing data in hash
by AnomalousMonk (Archbishop) on Mar 29, 2014 at 20:33 UTC
    print map { $_->{State} if $_->{ID} == 32 } @{ $hash->{data} };

    ccfc1986: Be aware that the processing of this data flow is IMHO problematic. For every element processed that does not match the desired  ID an extraneous empty string is returned (the  '' pairs in the example below), the result of the false evaluation of the  if conditional expression. I think NetWallah's use of grep is preferable.

    c:\@Work\Perl\monks>perl -wMstrict -le "my $hash = { 'data' => [ { 'ID' => 32, 'State' => 'Stopped' }, { 'ID' => 33, 'State' => 'Stopped' }, { 'ID' => 31, 'State' => 'Running' }, ], }; ;; my @ra = map { $_->{State} if $_->{ID} == 32 } @{ $hash->{data} }; printf qq{'$_' } for @ra; " 'Stopped' '' ''