Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Review and Suggestions - My First Module

by tcf03 (Deacon)
on Dec 11, 2007 at 06:08 UTC ( [id://656324]=note: print w/replies, xml ) Need Help??


in reply to Review and Suggestions - My First Module

I do something similar but have a sub for each type of DB - often times you need to set environmental vars, or some databases require different information passed ( or not ).

sub MSSQLConnect { my $ds = shift; my $db = shift; my $user = shift; my $pass = shift; $ENV{SYBASE} = '/usr/local'; $ENV{DSQUERY} = $ds; my $dbh = DBI->connect("dbi:Sybase:database=$db", $user, $pass ) or return "Unable to connext to $ds: $!"; return $dbh; } sub INFORMIXConnect { my $server = shift; my $db = shift; #my $user = shift; #my $pass = shift; $ENV{INFORMIXSERVER} = $server; $ENV{ONCONFIG} = "${server}.onconfig"; $ENV{INFORMIXDIR} = '/opt/informix'; #$ENV{DBDATE} = 'MDY4-'; #$ENV{DBTIME} = '%I:%M:%S'; $ENV{PATH} = '/usr/local/bin:/usr/bin:/bin:$ENV{INFORMIX +DIR}/bin'; my $dsn = "dbi:Informix:$db"; my $dbh = DBI->connect("$dsn") or #, $user, $pass) or return "Unable to connect to $server: $!\n"; return $dbh; }
Ted
--
"That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved."
  --Ralph Waldo Emerson

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://656324]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-05-18 06:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found