ccfc1986 has asked for the wisdom of the Perl Monks concerning the following question:
I want to be able to loop through the data, and check the current JobID, when i find a match (say 33) i want to grab the State field and do a check against it. How would this be possible? I tried the following:Dumping$VAR1 = { 'data' => [ { 'ID' => 32, 'State' => 'Stopped' }, { 'ID' => 33, 'State' => 'Stopped' }
Which prints the CurrentState - but its blank as im accessing it incorrectly. So i am able to get to the point where i know JobID = 15, but i can't get the current state field correctly. Cheersforeach my $value (sort keys $states->{data}) { if ($value == 15) { $CurrentState = $states->{data->{'State}'}; print "In here because found state of 15\n"; print "CurrentState; [$CurrentState]\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: accessing data in hash
by kcott (Archbishop) on Mar 29, 2014 at 10:46 UTC | |
|
Re: accessing data in hash
by 2teez (Vicar) on Mar 29, 2014 at 05:39 UTC | |
by AnomalousMonk (Archbishop) on Mar 29, 2014 at 20:38 UTC | |
by kcott (Archbishop) on Mar 29, 2014 at 21:43 UTC | |
|
Re: accessing data in hash
by NetWallah (Canon) on Mar 29, 2014 at 06:00 UTC | |
by AnomalousMonk (Archbishop) on Mar 29, 2014 at 20:33 UTC | |
|
Re: accessing data in hash
by Laurent_R (Canon) on Mar 29, 2014 at 12:37 UTC | |
|
Re: accessing data in hash
by ccfc1986 (Initiate) on Mar 29, 2014 at 15:16 UTC |