in reply to Re: Re:^4 Double Hash Key
in thread Double Hash Key

I decided to widdle your code to:

sub getTop25{ my $dbh = DBI->connect('DBI:ODBC:cdratelistingservice','$db','$pss +wd'); # ODBC connect print "Error opening database: $DBI::errstr\n" and exit unless $db +h->ping; my $connected = $dbh->ping; $dbh->{FetchHashKeyName}='NAME_lc'; my @fields = ( "30_day", "60_day", "90_day", "180_day", "270_day", + "1_year", "18_month", "2_year", "3_year", "4_year", "5_year", "v +ariable_1", "variable_2", "variable_3" ); for my $i (0..$#fields) { %complex = %{ merge( \%complex, $dbh->selectall_hashref( "Select TOP 25 $fields[$i], key from cdrates c, main m WHERE +r.key = m.key and m.valid = '$date' ORDER BY $fields[$i] DESC", "key" ) ) }; } print "\n\t",scalar keys %complex," RECORDS Found\n"; } sub GetStationNumbers{ my $dbh = DBI->connect('DBI:ODBC:poop'); # ODBC connect print "Error opening database: $DBI::errstr\n" and exit unless $dbh- +>ping; my $connected = $dbh->ping; $dbh->{FetchHashKeyName}='NAME_uc'; foreach my $key (sort keys %complex) { %complex = %{ merge( \%complex, $dbh->selectall_hashref( "SELECT station_number FROM inst where key = '$key'", # $key? "key" ) ) }; } $HoH_ref = \%complex; # $HoH_ref is a global? return scalar keys %complex; }

You seem to use globals quite excessively. This is usually considered to be a bad thing unless you explicitly wish to offer access through through them. Of course, you may be declaring these globals with my which is a very bad thing if you ever wish to move to mod_perl. A problem that exists with both of our code is that we fail to check whether or not the database queries are successful or not. I'm also curious, are you using strict and warnings?

antirice    
The first rule of Perl club is - use Perl
The
ith rule of Perl club is - follow rule i - 1 for i > 1