homer4all has asked for the wisdom of the Perl Monks concerning the following question:
Sample: tnsentry.txt#!/usr/bin/perl use strict; my $uNamePass = "user/password"; my @dbName; #Uses username password and dbName to connect databsae # e.g. user/password@db1 foreach my $item(@dbName) { $dbConnect = &connect($uNamePass."@".$dbName); &getRows; } exit($exitStatus); #------------ sub readFile { my $fName = "c:\tnsentry.txt"; my $dbName; # open file if ( ! open (DAT, $fName) ) { ¨ } # read file by each line while(<DAT>) { chomp; # if line begins with # sign, proceed to next next if /^\#/; # Next not able to figure out how to read each line and store distin +ct # DB name in an array to use for login in $dbConnect # I think I need to sepearte SID with /SID/ and search for string ti +ll it reaches ')' }
"SID = db1" or "SID = dbn" can appear multiple times in the file so don't want to connect same database multiple times and run queryDB1= ( (ADDRESS = (PROTOCOL = TCP)) ... ... (CONNECT_DATA = (SID = db1)) ) DB2= ( (ADDRESS = (PROTOCOL = TCP)) ... ... (CONNECT_DATA = (SID = db2)) ) DB3= ( (ADDRESS = (PROTOCOL = TCP)) ... ... (CONNECT_DATA = (SID = db3)) ) DB_ONE= ( (ADDRESS = (PROTOCOL = TCP)) ... ... (CONNECT_DATA = (SID = db1)) ) DB_TWO= ( (ADDRESS = (PROTOCOL = TCP)) ... ... (CONNECT_DATA = (SID = db2 )) )
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl array with oracle db name
by wjw (Priest) on May 22, 2014 at 17:35 UTC | |
by homer4all (Acolyte) on May 22, 2014 at 19:33 UTC | |
by wjw (Priest) on May 22, 2014 at 20:12 UTC |