[San-Diego-pm] Scope

Joel Fentin joel at fentin.com
Sun Aug 1 23:41:09 CDT 2004

I am working on an application which has different programs (main 
modules) that all share the same database. ModifyProduct.pl, 
AddProduct.pl, and DeleteProduct.pl for example. And there are more. 
Only one runs at a time.

I can repeat lines like the following and many others in each program:

my $dbh;
$dbh = 
my $ref = $dbh->selectall_arrayref("$Select $From $Where $Order");

Or I can set up a package for all of that (Utility.pl) where I stick all 
such utilities. And if I do so, and if I open the database connection in 
the utility, I presume I must do ALL database work through the utility.

At the moment it feels handier to simply duplicate the above lines and 
many others in each main module.

I have no size or speed issues.


Currently I leave the connection to the database open until the program 
no longer runs. Perhaps I should open, do a select, and close with each 
call to the database?


Are there common practices I should be aware of? Any suggestions?

Joel Fentin    tel: 760-749-8863    FAX: 760-749-8864
Contact me:    http://fentin.com/me/ContactMe.html
Biz:           http://fentin.com
Personal:      http://fentin.com/me/

More information about the San-Diego-pm mailing list