Charles K. Clarkson wrote:

> : use DBI;
> : use DBD::ODBC; # can this live solely in the module?
>
>     You don't need this at all. DBI calls the appropriate driver
> from the connection string.

Oh. I wonder where I got that from.

>
>
> : use Common::CSAdmin; # this is my module
> :
> : my $dbh = GetDBHandle('DSN');
>
>     You are expecting GetDBHandle() to be imported into this
> namespace. You'll need to export it from Common::CSAdmin. Without
> a specific export you'll need to tell perl what namespace to look
> in.


Yep - sorted this one thanks.

>
> : sub GetDBHandle($) {
> :     my $dsn = shift(@_);
> :     my ($dbusr,$dbpwd,$server,$dbh);
> :     $dbusr = 'usr';
> :     $dbpwd = 'pwd';
> :     $server = 'server';
> :     $dbh = DBI-> connect("DBI:ODBC:$dsn", $dbusr, $dbpwd, {RaiseError =>
> : 1, PrintError => 1})  || die "Could not connect to datasource $dsn";
> :     return $dbh;
> : }
>
>     IIRC, RaiseError warns on errors and PrintError dies on errors.
> So your error message would never be seen. A DBI expert might shed
> more light on this, but you probably want this to avoid duplicate
> warn and die messages.

I'll have a play with this.

>
>
>     If you want to export functions into the callers namespace,
> check out the Exporter module. It is often considered bad form to
> automatically export functions. It is also easier to debug later
> if you specifically call functions while using the module. The
> strftime() function is a good example.
>
> use POSIX qw(strftime);
>
>     When debugging a script it sure helps to know where a
> mysterious subroutine came from.
>
>
>       An OO module for such a simple thing is probably going
> overboard. It makes for a nice programming exercise, but a
> function is not an object.
>
>
> HTH,
>
> Charles K. Clarkson
> --

Thanks for the input Charles. I need to go through the process of doing an
OO module at some point and I thought this might be a nice simple thing to
learn with. If it works so simply without any OO then I'll  probably leave
it for time's sake.

Best
Mark


_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to