<?xml version="1.0" encoding="windows-1252"?>
<node id="1004116" title="Re: MySQL hashes with same key" created="2012-11-15 22:30:26" updated="2012-11-15 22:30:26">
<type id="11">
note</type>
<author id="533863">
roboticus</author>
<data>
<field name="doctext">
&lt;p&gt;[jason.c.rochon]:&lt;/p&gt;
&lt;p&gt;You don't *have* to use arrays.  But it really depends on the result(s) you want.  If you want all three comments to be tied to the same key, you could read your data like:&lt;/p&gt;
&lt;c&gt;
my $sth=$dbh-&gt;prepare("select ....");
$sth-&gt;execute;

# Stuff all the data in a hash, concatenating all comments
my %Macs;
while (my $hr = $sth-&gt;fetchrow_hashref) {
    if (! exists $Macs{$$hr{mac}}) {
        $Macs{$$hr{mac}} = $$hr{comment};
    }
    else {
        $Macs{$$hr{mac}} .= $$hr{comment};
    }
}
&lt;/c&gt;
&lt;p&gt;You could have each hash key hold an array of comments, too.  It all boils down to how you're actually going to work with the data.&lt;/p&gt;
&lt;p&gt;...[roboticus]&lt;/p&gt;
&lt;p&gt;&lt;i&gt;When your only tool is a hammer, all problems look like your thumb.&lt;/i&gt;&lt;/p&gt;</field>
<field name="root_node">
1004111</field>
<field name="parent_node">
1004111</field>
</data>
</node>
