vili has asked for the wisdom of the Perl Monks concerning the following question:
i need to use a multipatrt key in (masterid,attribute_id) to to get complete data, i'm not sure how to use foreach in this case. please helpmy $attr_detail = $dbh->prepare("select pa.masterid,pa.pco_attribute_id,pa.pco_v +alue from attributes_short pa, pageids p, prodpg pg where p.page_id=pg.page_id and pg.masterid=pa.masterid;"); + + my (%details, $m_id, $attr_id); $attr_detail->execute(); while (my $r = $attr_detail->fetchrow_hashref()) { $m_id = $r->{'masterid'}; $attr_id = $r->{'pco_attribute_id'}; # $details{$m_id}{pco_attribute_id} = $r->{'pco_attribut +e_id'}; $details{$m_id,$attr_id}{pco_value} = $r->{'pco_value' +}; } + + open (DETAILS,">>attr_detail.tsv"); foreach $m_id (keys %details) { print DETAILS "$m_id\t$attr_id\t$details{$m_id,$attr_id}\n"; } close DETAILS;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: multipart key in hash, i'm confused
by Zed_Lopez (Chaplain) on Jan 19, 2004 at 20:28 UTC | |
|
Re: multipart key in hash, i'm confused
by tadman (Prior) on Jan 19, 2004 at 20:28 UTC | |
|
Re: multipart key in hash, i'm confused
by The Mad Hatter (Priest) on Jan 19, 2004 at 20:38 UTC |