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


In reply to Re: Re: Re:^4 Double Hash Key by antirice
in thread Double Hash Key by whaled

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.