Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: error handling with dbi

by crusty_collins (Friar)
on Feb 16, 2016 at 16:09 UTC ( [id://1155368] : note . print w/replies, xml ) Need Help??


in reply to error handling with dbi

I would not try the hit or miss approach.

use a file or put it in the script and define which database for each password.

Connect to each individually.

env.ini

CARDTESTSID = CARD1 CARDTESTSVER = card1 CARDTESTUSER = pass CARDTESTPASS = pass CARDTESTPRT = 1521 CARDSID = CARD2 CARDSVER = card2 CARDUSER = pass CARDPASS = pass CARDPRT = 1521 PRISMTESTSID = JET1 PRISMTESTSVER = jet1 PRISMTESTUSER = pass PRISMTESTPASS = pass PRISMTESTPRT = 1522 PRISMSID = JET2 PRISMSVER = jet2 PRISMUSER = pass PRISMPASS = pass PRISMPRT = 1522
A simple parser for .ini
sub getEnv { my $file = shift(@_); unless (-f $file) { print "Could not find $file.\n"; exit(1); } open (FILE, "< $file"); while (<FILE>) { chomp; next if /^\s*\#/; next unless /=/; my ($key, $variable) = split(/=/,$_,2); $variable =~ s/\s+//g; $key =~ s/\s+//g; $ref->{config}->{$key} = $variable; } close FILE; }
"We can't all be happy, we can't all be rich, we can't all be lucky and it would be so much less fun if we were. There must be the dark background to show up the bright colours." Jean Rhys (1890-1979)

Replies are listed 'Best First'.
Re^2: error handling with dbi
by gandolf989 (Scribe) on Feb 16, 2016 at 16:33 UTC
    Unfortunately, I don't create all of the databases. I query the databases that I need to connect to from a database. I just need to figure out the error handling and that should be enough. I will try using "not defined" in the if.