Try to create logical database requests, wrap those in perl subroutines, and place them in a separate module. This will greatly improve the readability of the main script, and will also improve maintainability.
Avoid "select * ..." SQL statements. Be explicit in what you are querying, even if that makes the code more verbose - it'll again improve maintainability.
One thing that is repeating a lot in the code is prepare/execute/fetch one row. Maybe you could use a utility subroutine that does that, something like:
Just using that could already simplify the code to a great extent.sub fetch_one_row { my $sql = shift; my $sth = $dbh->prepare($sql); $sth->execute; $sth->fetchrow_hashref; }
Michael
In reply to Re: Re-Factoring: Philosophy and Approach
by mpeppler
in thread Re-Factoring: Philosophy and Approach
by George_Sherston
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |