As a side note, you may want to also lookinto the
DBI::fetchrow_arrayref() whereas having DBI return a reference to an array rather than a copy of the extraced array has tended to be
faster. You can think of it in the light of having DBI return a pointer to the particular segment of memory where the data is rather than returning all the data in memory.
The only change you would have to make, in this example (rather than re-naming the method call) would be to de-reference the array reference as you are looking to use the values within it. Therefore you could:
# Assuming you like the idea of scoping two variables
# lexically within the while block as noted in previous
# comments
while ( my ( $page_title, $hit_count ) = @{ $cursor->fetchrow_arrayref
+() } ) {
$page_hits{$page_title} = $hit_count;
}
You will see that the supplimental change to the logic would be the addition of the
@{} block, telling Perl to de-reference the array reference returned from
fetchrow_arrayref
Not a big deal, in most (some) cases, but certainly something to think about.
print map{chr}(45,45,104,97,124,124,116,97,45,45);
... and I probably posted this while I was at work => whitepages.com | inc.