[Chicago-talk] Hash Question

Alan Mead amead2 at alanmead.org
Sat Oct 3 14:04:18 PDT 2015


I don't understand what you're doing, so I don't know if this helps but
you have an 'opp_team' for keys 11 and 12. You need to access them like
a multidimensional array: 

print $VAR1->{'11'}->{'opp_team'},"\n";
print $VAR1->{'12'}->{'opp_team'},"\n";

This also works:

print "$VAR1->{12}->{opp_team}\n";

-Alan


On 10/3/2015 11:59 AM, richard at rushlogistics.com wrote:
> I have a hash reference with that originates from a DBI fetch  $sth->fetchall_hashref('ID'); and has the following structure:
>
> $VAR1 = {
>           '12' => {
>                     'opp_team' => 'Storm',
>                     'GAME_ID' => '1',
>                     'DATE_FORMAT(g.DATE,\'%m-%d-%y\')' => '09-04-15',
>                     'NAME' => 'Strikeout',
>                     'STATUS' => 'PNDG',
>                     'ACC_TYPE_ID' => '11',
>                     'ID' => '12',
>                     'PERIOD' => '1',
>                     'TIME_DENOM' => 'inning'
>                   },
>           '11' => {
>                     'ID' => '11',
>                     'ACC_TYPE_ID' => '11',
>                     'TIME_DENOM' => 'inning',
>                     'PERIOD' => '1',
>                     'NAME' => 'Strikeout',
>                     'DATE_FORMAT(g.DATE,\'%m-%d-%y\')' => '09-04-15',
>                     'GAME_ID' => '1',
>                     'opp_team' => 'Storm',
>                     'STATUS' => 'PNDG'
>                   }
>         };
>
> Is there a way to access one element in the hash reference? I am trying print "Opp Team: $logro_ref->{'opp_team'}\n"; with no success. 
>
> Thanks
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk

-- 

Alan D. Mead, Ph.D.
President, Talent Algorithms Inc.

science + technology = better workers

+815.588.3846 (Office)
+267.334.4143 (Mobile)

http://www.alanmead.org

Announcing the Journal of Computerized Adaptive Testing (JCAT), a
peer-reviewed electronic journal designed to advance the science and
practice of computerized adaptive testing: http://www.iacat.org/jcat



More information about the Chicago-talk mailing list