Digest, Vol 30, Issue 38

Jonathan Stowe jns at
Thu Apr 10 10:00:20 BST 2008

On Thu, 2008-04-10 at 09:17 +0100, Hemant Verma wrote:
> Hi,
> This is in the response of Ovid <publiustemp-londonpm at>.
> Actually Perl exeucte die command.
> I have following command. It shows "Can't connect to TM V6 (dsn=$my_dsn)"
> message in the browser. It means it is not able to connect with this
> database.
> If I execute this script in komodo itself then it is able to connect with
> the database successfully.
> That's what I want if there is any extra restriction on using cgi or perl
> script from browser.
> $tmdb   =   new Win32::ODBC("DSN=$my_dsn; UID=USER; PWD=pwd") or die "Can't
> connect to TM V6 (dsn=$my_dsn)\n";

You aren't printing out any useful diagnostic information in the "die"
message. You probably want to use the Error() method as described in the
module's documentation. I could speculate with a certain degree of
accuracy what the problem is but I think it should be clear if you have
useful diagnostic information.

Also (though some might consider this a matter of taste I don't actually
believe it is), you have cargo-culted the indirect object syntax of the
constructor call from the documentation.  You really, really want to use
the direct syntax indicated by the '->', if only for no other reason
than you don't want people to point and laugh at your code.

Also (II) unless you have some compelling reason not to you probably
want to use DBI (and DBD::ODBC) for new code as this has a number of
advantages, including: better documentation, greater familiarity to the
majority of Perl programmers and greater portability of the code to
other platforms and databases. 

Make war on hippies

More information about the mailing list