dhudnall has asked for the wisdom of the Perl Monks concerning the following question:
-Therefore, after executing this code I have a list of tables but what I REALLY WANT is a the DB along with the table name. The file that contains an ENTIRE listing of all DB names along with their tables is DatabaseTables.txt. I just want to be able to search through that file using the tables that I found in the first search to pull the ENTIRE listing (DB & TABLENAME). Please help if you can.#This will open the file that will contain the list of tables open(TABLES, '<DBtest.txt') or die "The file DBnames.txt could not be +opened\n"; #This will open the file that will contain the list of SQL statements +to be parsed open(DOUT, '<databaseJoinDan.txt') or die "The file databaseJoinDan.tx +t could no t be opened\n"; #This will open the file that will be written to containing the list o +f tables #in the SQL files open(USED, '>>tableUsed.txt') or die "The file tablesUsed.txt could no +t be writt en to\n"; #This will convert the files into lists to be searched @tableList=<TABLES>; @fileList=<DOUT>; @tableUsed=<USED>; #declarations $Y=0; $T=0; #This will search through the files and see if the tables exist in the + file chomp @tableList; chomp @fileList; for $Y (@tableList){ for $T (@fileList){ if($T =~ /$Y/i){ print USED "$Y\n"; } } }#end of the for loop close(DOUT); close(TABLES); close(USED);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: comparing 2 files
by jdporter (Paladin) on Jun 19, 2007 at 18:00 UTC | |
|
Re: comparing 2 files
by graff (Chancellor) on Jun 20, 2007 at 03:19 UTC | |
by dhudnall (Novice) on Jun 20, 2007 at 14:56 UTC | |
by graff (Chancellor) on Jun 21, 2007 at 02:50 UTC |