in reply to Re: Hash throws out duplicate values
in thread Hash throws out duplicate values
I was going to use a hash of arrays, but that will get messy real quick. So how would I use a while loop to connect to my database and populate each record of the hash? Here's my current code:
while (my $records = $query_handle->fetchrow_hashref) { my $new_name = $records->{'ap_name'}; my $location = $records->{'building'}; my $first_name = $records->{'primary_name'}; my $first_ip = $records->{'primary_ip'}; my $second_name = $records->{'secondary_name'}; my $second_ip = $records->{'secondary_ip'}; my $third_name = $records->{'tertiary_name'}; my $third_ip = $records->{'tertiary_ip'}; my $group = $records->{'bldg_short'}; my $five_channel = $records->{'five_channel'}; my $configured = $records->{'configured'}; my $mac_name = $records->{'mac_name'}; #Add each element as a hash to an Array of Hashes (AoH) my $new_hash = { new_name => $new_name, location => $location, first_name => $first_name, first_ip => $first_ip, second_name => $second_name, second_ip => $second_ip, third_name => $third_name, third_ip => $third_ip, group => $group, five_channel => $five_channel, configured => $configured, mac_name => $mac_name }; push (@aps, $new_hash); }
Can I step through the array 'records' and enter unique records using a loop with $i? I don't know where to place the $i to make it work.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Hash throws out duplicate values
by ikegami (Patriarch) on Oct 12, 2009 at 09:17 UTC | |
|
Re^3: Hash throws out duplicate values
by Marshall (Canon) on Oct 12, 2009 at 10:20 UTC | |
by spickles (Scribe) on Oct 15, 2009 at 14:53 UTC | |
by Marshall (Canon) on Oct 15, 2009 at 18:30 UTC |