Message from discussion
Help with Hash Array
Received: by 10.68.130.100 with SMTP id od4mr1146829pbb.2.1335818426001;
Mon, 30 Apr 2012 13:40:26 -0700 (PDT)
Path: r9ni117072pbh.0!nntp.google.com!news2.google.com!postnews.google.com!e42g2000yqa.googlegroups.com!not-for-mail
From: ExecMan <artme...@yahoo.com>
Newsgroups: comp.lang.perl.misc
Subject: Help with Hash Array
Date: Mon, 30 Apr 2012 13:40:25 -0700 (PDT)
Organization: http://groups.google.com
Lines: 43
Message-ID: <cdcde8e7-9b47-4b3e-b09b-a0d6febb0f2a@e42g2000yqa.googlegroups.com>
NNTP-Posting-Host: 208.65.116.5
Mime-Version: 1.0
X-Trace: posting.google.com 1335818425 6812 127.0.0.1 (30 Apr 2012 20:40:25 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 30 Apr 2012 20:40:25 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: e42g2000yqa.googlegroups.com; posting-host=208.65.116.5; posting-account=Te8R5QoAAAD0OcZ51Bsj60HqyktlOVZb
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.10)
Gecko/20100914 Firefox/3.6.10,gzip(gfe)
Content-Type: text/plain; charset=ISO-8859-1
Hi,
I have a somewhat complex hash array, below. I want to know how to
access individual items within the inner hash.
With the example below, say I need the SUBJECT: $subj =
$SERVICES{'tactical'}->{subject};
However, say I need to get the COMMAND from the ALERT array with the
name SENDBUY. The value I am looking for is: trader.pl -B
But I am not sure how to turn the ALERT item into a hash so I can
access it by value, rather than by an array index.
Can anyone help??
%SERVICES = (
'tactical' => {
'service' => "tactical",
'url' => "tacticaltrader",
'from' => "Tactical Trader <tacticaltrader\@mail.com>",
'mailer' => "Tactical Trader Mailer",
'subject' => "Tactical Trader Summary",
'alert' => [
{ 'name' => "GENERATE", 'html' =>
"sid=group_id=29&ctype=0", 'command' => "eod-trader.pl -t -M",},
{ 'name' => "GENERATEBUY", 'html' =>
"sid=group_id=29&ctype=1", 'command' => "trader.pl -t -B -M",},
{ 'name' => "GENERATESELL", 'html' =>
"sid=group_id=29&ctype=2", 'command' => "trader.pl -t -S -M",},
{ 'name' => "SEND", 'html' =>
"sid=group_id=29&ctype=0", 'command' => "eod-trader.pl",},
{ 'name' => "SENDBUY", 'html' =>
"sid=group_id=29&ctype=1", 'command' => "trader.pl -B",},
{ 'name' => "SENDSELL", 'html' =>
"sid=group_id=29&ctype=2", 'command' => "trader.pl -S",},
{ 'name' => "GENERATEINTRA",'html' =>
"sid=group_id=29&ctype=3", 'command' => "trader.pl -t -I -M",},
{ 'name' => "SENDINTRA", 'html' =>
"sid=group_id=29&ctype=3", 'command' => "trader.pl",},
],
},
)