dhudnall has asked for the wisdom of the Perl Monks concerning the following question:
#----------------------------------------------- I have tried several solutions as you can see with the commented lines that were once statements. Please if you know of a way I can do this, it will tremendously help me with my project. I am new to PERL and therefore am just beginning to learn the syntax and its capabilities. Thanks#---------------------------------------------------- #This section will contain the searched for the DB tables in the SQL f +iles #and return all lines that contain an instance of a DB table. #This will open the file that will contain the list of tables open(TABLES, '<DBtables1.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 pars ed open(UPDATE, '<updateDan.txt') or die "The file updateDan.txt could no +t be opene d\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=<UPDATE>; @tableUsed=<USED>; #declarations $W=0; $Q=0; #This will search through the files and see if the tables exist in the + file foreach $W (@tableList) { foreach $Q (@fileList) { #if (exists($Q{$W})) if($W==$Q) { #print TABLE "$W\n"; push(@tableUsed, $W); print USED @tableUsed; }#end of if else { print USED "no tables exist in the file\n"; } } }#end of foreach loop close(UPDATE); close(TABLES); close(USED);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: comparing 2 lists
by citromatik (Curate) on Jun 19, 2007 at 14:26 UTC | |
|
Re: comparing 2 lists
by scorpio17 (Canon) on Jun 19, 2007 at 15:02 UTC | |
by ikegami (Patriarch) on Jun 19, 2007 at 15:32 UTC | |
|
Re: comparing 2 lists
by santhi (Monk) on Jun 20, 2007 at 07:30 UTC |