while(@results = $sth -> fetchrow_array) { $index++; $SearchResults[$index]{'id'} = $results[0]; $SearchResults[$index]{'searchterm'} = $results[1]; $SearchResults[$index]{'magazinetitle'} = $results[2]; $SearchResults[$index]{'issueno'} = $results[3]; $SearchResults[$index]{'startpage'} = $results[4]; $SearchResults[$index]{'endpage'} = $results[5]; $SearchResults[$index]{'buynow'} = $results[6]; $SearchResults[$index]{'index'} = $index; $SearchResults{'count'} += 1; }
with
{ my $i = {}; @SearchResults = @{$sth->fetchall_arrayref($i)}; $SearchResults{count} = ++$#SearchResults; }
...just 'cuz I'm guessing DBI's faster than you are. ;-)
Looks like you could hoist a bunch of stuff out of those loops in your subroutines, too. But as I see ".asp" which stands for "Ain't Stuff for Petruchio", I'll leave that to the smarter monks... many of whom will doubtless tell you to use strict, by the way.
In reply to Re: Help required to improve code
by Anonymous Monk
in thread Help required to improve code
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |