starburst has asked for the wisdom of the Perl Monks concerning the following question:
I am pretty sure my if (exists) and if (defined) statements are wrong/not the best way...but if you have some sort of idea of how I can continue to search for associated ID numbers if there are multiple instances of a user in the database I would appreciate it. Thanks Monks!# Display content of search while ( $ref = $sth->fetchrow_hashref()) { # $uniqueKey is the column 'user' from the DB. (ie $key is the spec +ific user name) $key = $ref->{$uniqueKey}; # GetSystem uses the user name to get the associated ID number from + DB1, and uses that value to get an associated system name from DB2 my $systemKey = GetSystem($key); if (exists $referenceTable{$key}) { if (defined $referenceTable{key} eq $systemKey) { # do i need to do this? } else { push @{$referenceTable{$key}}, $systemKey; } } else { push @{$referenceTable{$key}}, $systemKey; } } my ($k,@v); print "<table>"; print "<tr><th>User</th><th>System</th></tr>\n"; # SET UP THE TABLE # EXECUTE THE WHILE LOOP while (($k, $v) = each(%referenceTable)){ print "<tr><td>".$k."</td>"; print "<td>"; foreach (@$v) { print "$_\n"; } print"</td></tr>"; } print"</table>\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash table with no fully distinct keys
by toolic (Bishop) on Apr 16, 2010 at 22:00 UTC | |
|
Re: Hash table with no fully distinct keys
by graff (Chancellor) on Apr 17, 2010 at 01:35 UTC | |
|
Re: Hash table with no fully distinct keys
by umasuresh (Hermit) on Apr 16, 2010 at 19:48 UTC | |
|
Re: Hash table with no fully distinct keys
by rev_1318 (Chaplain) on Apr 17, 2010 at 19:40 UTC |