in reply to Why should I use Exporter?
.. and a MyDB.pm...# Constructor # Usage: $MyDB = DB::MyDB->dbconnect("db", "username", "pwd") sub dbconnect { # stuff } # Usage: $tbl = $MyDB->selectall_tbl($select_statement) # where $tbl is a 2D array sub selectall_tbl { # stuff } 1 ;
... and a MyWebDB.pmpackage DB::MyDB ; require Exporter ; @ISA = qw(Exporter) ; @EXPORT = qw(print_tbl) ; use DBI ; use strict ; use DB::_DB ; # OO stuff # Usage: print_tbl($tbl) # where $tbl = $MyDB->selectall_tbl($select_statement) # return nice text result sub print_tbl { # stuff } 1 ;
_DB.pm contains all the OO stuff for DB access--which basically forms a base object. But there are an Apache environment and a regular environment, where you might need additional methods/subroutines specific for them respectively. Well, you could write some child objects, which inherit the base object from _DB.pm, with additional methods.package DB::MyWebDB ; use Apache::Reload ; use strict ; use DB::_DB ; # OO stuff 1 ;
|
|---|