<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1015814" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1015814</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/comparing-fields-1-database-fields-another#comment-1091757</link>
    <description> &lt;p&gt;That&#039;s great, pretty compact code too!&lt;/p&gt;
 </description>
     <pubDate>Wed, 17 Oct 2001 14:34:53 +0000</pubDate>
 <dc:creator>Peter J. Boettcher</dc:creator>
 <guid isPermaLink="false">comment 1091757 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Code Completed...</title>
    <link>https://www.webmaster-forums.net/serverside-scripting/comparing-fields-1-database-fields-another#comment-1091755</link>
    <description> &lt;p&gt;Hi Mark &amp;amp; Peter (and anyone else),&lt;/p&gt;
&lt;p&gt;I&#039;ve come up with something that does the job. I don&#039;t know how &quot;clean&quot; the code is, but it does exactly what I needed.&lt;/p&gt;
&lt;p&gt;So, in case anyone can use it, here it is. Of course, if anyone wants to offer improvements on it, please feel free...&lt;/p&gt;
&lt;p&gt;Thanks for the help I received...&lt;/p&gt;
&lt;p&gt;#!/usr/bin/perl&lt;/p&gt;
&lt;p&gt;print &quot;Content-type: text/html\n\n&quot;;&lt;br /&gt;
$file1 = &quot;file1.txt&quot;;&lt;br /&gt;
$file2 = &quot;file2.txt&quot;;&lt;br /&gt;
open(FILE1,&quot;&amp;lt;$file1&quot;);&lt;br /&gt;
@file1 = ;&lt;br /&gt;
close(FILE1);&lt;br /&gt;
open(FILE2,&quot;&amp;lt;$file2&quot;);&lt;br /&gt;
@file2 = ;&lt;br /&gt;
close(FILE2);&lt;/p&gt;
&lt;p&gt;$matches = 0;		#set the matches counter&lt;br /&gt;
foreach $line ( @file1 ) {	#look at a line in file 1&lt;br /&gt;
    foreach $line2 ( @file2 ) {		#then, look at a line in file 2&lt;br /&gt;
	@array1 = split (/\|/, $line);		#turn the first line into an array&lt;br /&gt;
	@array2 = split (/\|/, $line2);		# turn the 2nd line into an array&lt;br /&gt;
	$numavail = @array1;&lt;br /&gt;
	$limit = $numavail - 3;		# limit is the last of the fields I want to consider for matches&lt;br /&gt;
		for ( $i=12; $i &amp;lt; $limit; $i++ )  {&lt;br /&gt;
			if ( $array1[$i] eq $array2[$i] ) {# compare the corresponding fields in each line&lt;br /&gt;
			$matches++;		# keeps track of how many matches line to line&lt;br /&gt;
	       		}		# end the if&lt;br /&gt;
    		}			# end the for&lt;br /&gt;
		if ( $matches &amp;gt;= 1 &amp;amp;&amp;amp; $array1[14] ge $array2[14] &amp;amp;&amp;amp; $array1[12] le $array2[12]) {	# if the matches are &quot;right&quot;&lt;/p&gt;
&lt;p&gt;			print &quot;Here is where I print the data I want to retreive, using things like $array1[12] etc&quot;;&lt;br /&gt;
		}		# end the 2nd if&lt;br /&gt;
	$matches = 0;		# reset the counter so the number of matches don&#039;t continually increase&lt;br /&gt;
	}			# end the 2nd foreach&lt;br /&gt;
}				#end the 1st foreach&lt;/p&gt;
 </description>
     <pubDate>Wed, 17 Oct 2001 14:12:53 +0000</pubDate>
 <dc:creator>rline</dc:creator>
 <guid isPermaLink="false">comment 1091755 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/comparing-fields-1-database-fields-another#comment-1091725</link>
    <description> &lt;p&gt;I see you fixed my split() function.  I missed that.  I&#039;m not really the perl expert here, it&#039;s really been too long.&lt;/p&gt;
&lt;p&gt;I&#039;m not sure how perl handles pringing @arrays.  You may have to loop through the elements and print them.&lt;/p&gt;
&lt;p&gt;You don&#039;t need to post the 2 flat files.  All we need is the format, which you provided.&lt;/p&gt;
 </description>
     <pubDate>Wed, 17 Oct 2001 07:13:01 +0000</pubDate>
 <dc:creator>Mark Hensler</dc:creator>
 <guid isPermaLink="false">comment 1091725 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/comparing-fields-1-database-fields-another#comment-1091720</link>
    <description> &lt;p&gt;Hi Mark,&lt;/p&gt;
&lt;p&gt;Thanks again. Short answer is it doesn&#039;t work (yet!) But there are no error messages, and I may have found where a problem is. Below is the bit I&#039;m interested in. You&#039;ll notice I threw in a couple of print statements, to see what was printing.&lt;/p&gt;
&lt;p&gt;So, $num_lines1 is correct, so it&#039;s working up to there. Then I tell it to print the array @pieces, which it does, but only the first of the 2 lines. (but it&#039;s only supposed tp print the first line at that stage, isn&#039;t it?)&lt;/p&gt;
&lt;p&gt;When I tell it to print both @arrFile1 and $num_fields1, it prints neither. Which makes me think perl&#039;s happy to do the code up to the creation of @arrFile1.&lt;/p&gt;
&lt;p&gt;Would it help for me to include the 2 flatfiles?&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;##### Code here #####&lt;br /&gt;
# count the number of lines&lt;br /&gt;
$num_lines1 = @file1;&lt;br /&gt;
print &quot;$num_lines1&quot;;&lt;br /&gt;
$i=0;&lt;/p&gt;
&lt;p&gt;# loop through lines in file 1&lt;br /&gt;
for ($x=1; $x&amp;lt;=$num_lines1; $x++) {&lt;/p&gt;
&lt;p&gt;    # split the line into pieces so each field is an element in an array&lt;br /&gt;
    # $pieces[0] = &quot;field_one_value&quot;;&lt;br /&gt;
    # $pieces[1] = &quot;field_two_value&quot;;&lt;br /&gt;
    # ...&lt;br /&gt;
    @pieces1 = split(/\|/, $file1[$i]);&lt;br /&gt;
print &quot;@pieces1\n&quot;;&lt;br /&gt;
    # loop through the array we just created&lt;br /&gt;
    foreach $thing1 (@pieces1) {&lt;/p&gt;
&lt;p&gt;        # now, smash the pieces together into yet another array&lt;br /&gt;
        # $arrFile1 = array(line number, value)&lt;br /&gt;
        $arrFile1[$i] = array($x, $thing1);&lt;br /&gt;
        $i++;&lt;br /&gt;
    }&lt;br /&gt;
$num_fields1 = @arrFile1;&lt;/p&gt;
&lt;p&gt;} #END for&lt;br /&gt;
print &quot;$num_fields1&quot;;&lt;br /&gt;
print &quot;@arrFile1&quot;;&lt;br /&gt;
# @arrFile1 now contains all the fields from file 1 in the following format:&lt;br /&gt;
# $arrFile1[x] = array(line number, value);&lt;br /&gt;
#&lt;br /&gt;
# example:&lt;br /&gt;
# $arrFile1[0] = array(1, &quot;field_one_value&quot;);&lt;br /&gt;
# $arrFile1[1] = array(1, field_two_value&quot;);&lt;br /&gt;
# ...&lt;br /&gt;
# $arrFile1[9] = array(1, &quot;field_ten_value&quot;);&lt;br /&gt;
# $arrFile1[10] = array(2, &quot;field_one_value&quot;);&lt;/p&gt;
 </description>
     <pubDate>Wed, 17 Oct 2001 05:12:51 +0000</pubDate>
 <dc:creator>rline</dc:creator>
 <guid isPermaLink="false">comment 1091720 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/comparing-fields-1-database-fields-another#comment-1091718</link>
    <description> &lt;p&gt;Made some changes... (also added more comments to help you visualize)&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;#!/usr/bin/perl &lt;br /&gt;&lt;br /&gt;$file1 = &amp;quot;available.txt&amp;quot;; #my first database &lt;br /&gt;$file2 = &amp;quot;needed.txt&amp;quot;; # my 2nd database &lt;br /&gt;&lt;br /&gt;# open file 1&lt;br /&gt;open(FILE,&amp;quot;&amp;lt;$file1&amp;quot;); &lt;br /&gt;# suck it into an array&lt;br /&gt;@file = &amp;lt;FILE&amp;gt;;&lt;br /&gt;# close the file&lt;br /&gt;close(FILE);&lt;br /&gt;&lt;br /&gt;# count the number of lines&lt;br /&gt;$num_lines = @file;&lt;br /&gt;&lt;br /&gt;$i=0;&lt;br /&gt;&lt;br /&gt;# loop through lines in file 1 &lt;br /&gt;for ($x=1; $x&amp;lt;=$num_lines; $x++) {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # split the line into pieces so each field is an element in an array&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # $peices[0] = &amp;quot;field_one_value&amp;quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # $peices[1] = &amp;quot;field_two_value&amp;quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # ...&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @pieces = split(&amp;quot;|&amp;quot;, $file[$i]);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # loop through the array we just created&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach $thing (@pieces) {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # now, smash the pieces together into yet another array&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # $arrFile1 = array(line number, value)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @arrFile1[$i] = array($x, $thing); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $i++; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;} #END for&lt;br /&gt;&lt;br /&gt;# @arrFile1 now contains all the fields from file 1 in the following format:&lt;br /&gt;# $arrFile1[x] = array(line number, value);&lt;br /&gt;#&lt;br /&gt;# example:&lt;br /&gt;# $arrFile1[0] = array(1, &amp;quot;field_one_value&amp;quot;);&lt;br /&gt;# $arrFile1[1] = array(1, field_two_value&amp;quot;);&lt;br /&gt;# ...&lt;br /&gt;# $arrFile1[9] = array(1, &amp;quot;field_ten_value&amp;quot;);&lt;br /&gt;# $arrFile1[10] = array(2, &amp;quot;field_one_value&amp;quot;);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# do it all again for file 2&lt;br /&gt;open(FILE2, &amp;quot;&amp;lt;$file2&amp;quot;); &lt;br /&gt;@file = &amp;lt;FILE&amp;gt;;&lt;br /&gt;close(FILE2);&lt;br /&gt;$num_lines = @file; &lt;br /&gt;# loop through lines in file 2 &lt;br /&gt;$i=0; &lt;br /&gt;for ($y=1; $y&amp;lt;=$num_lines; $y++) { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @pieces = split(&amp;quot;|&amp;quot;, $file[$i]); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach $thing (@pieces) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # $arrFile2 = array(line number, value)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @arrFile2[$i] = array($y, $thing); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $i++; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;} &lt;br /&gt;# @arrFile2 now contains all the fields from file 2&lt;br /&gt;&lt;br /&gt;# count the number of elements in each array&lt;br /&gt;$num_fields1 = @arrFile1;&lt;br /&gt;$num_fields2 = @arrFile2;&lt;br /&gt;&lt;br /&gt;# loop through the fields from file 1&lt;br /&gt;for ($x=1; $x&amp;lt;=$num_fields1; $x++) {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # loop through the fields from file 2&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for ($y=1; $y&amp;lt;=$num_fields2; $y++) {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # if the field from file 1 matches the field from file 2&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($arrFile1[$x][1] == $arrFile1[$x][1]) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # store the line from file 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $arrResult[$x][0] = $arrFile1[$x][0];&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # store the value of the field&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $arrResult[$x][1] = $arrFile1[$x][1];&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # store the line from file 2&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $arrResult[$x][2] = $arrFile2[$y][0];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } #END if&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # increment the number of matches for this field in file 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $intMatches = $intMatches + 1;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } #END for (file2)&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # I&amp;#039;m not sure what this does...&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # looks like its saving the last field in file 2 that this field in file 1 matched&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # I&amp;#039;m probably wrong, print it and find out&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $arrMatches[$x][0] = $arrFile2[$y][0];&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # save the number of times this field from file 1 matched a field from file 2&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $arrMatches[$x][1] = $intMatches;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # reset the counter&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $intMatches = 0; &lt;br /&gt;} #END for (file1)&lt;br /&gt;&lt;br /&gt;print &amp;quot;Content-type: text/html&amp;quot;, &amp;quot;\n\n&amp;quot;; &lt;br /&gt;print &amp;quot;$num_lines1&amp;lt;br&amp;gt;$num_lines2&amp;lt;br&amp;gt;$num_fields1&amp;lt;br&amp;gt;$num_fields2&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;\n&amp;quot;; &lt;br /&gt;foreach $line (@arrMatches) { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print &amp;quot;$line\n\n&amp;quot;; &lt;br /&gt;} &lt;br /&gt;print &amp;quot;$intMatches\n&amp;quot;;&lt;/code&gt;&lt;/div&gt;&#039;Does it work now?&lt;br /&gt;
I corrected some things, and re-used vars to save memory.&lt;/p&gt;
 </description>
     <pubDate>Wed, 17 Oct 2001 04:14:50 +0000</pubDate>
 <dc:creator>Mark Hensler</dc:creator>
 <guid isPermaLink="false">comment 1091718 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/comparing-fields-1-database-fields-another#comment-1091716</link>
    <description> &lt;p&gt;G&#039;day Peter and Mark,&lt;/p&gt;
&lt;p&gt;Mark, you win the bet. I am using perl, and my two databases are delimited by |. Thanks for both your replies.&lt;/p&gt;
&lt;p&gt;Below I&#039;ve added your code, which I modified slightly where I thought changes needed to be made. I also commented certain lines, to reflect what I understand is going on, and so you can set me straight if I don&#039;t.&lt;/p&gt;
&lt;p&gt;Good news is there are no error messages.&lt;/p&gt;
&lt;p&gt;You&#039;ll notice I asked it to print to the screen, the number of lines in each of the 2 files (which it did successfully, so I know that part has worked), and the number of elements in the two arrays @arrFile1 and @arrFile2. It printed &quot;0&quot; and &quot;0&quot; for each of these values, so I think this may be part of the problem. There seems to be no elements in either of these arrays.&lt;/p&gt;
&lt;p&gt;As to matching, I have included the exact same line in each of the files, so I know that if the code works, I should get at least one line in file 1 which completely matches with a line in file 2.&lt;/p&gt;
&lt;p&gt;Anyway, any comnents and help will be appreciated!&lt;/p&gt;
&lt;p&gt;Thanks...&lt;/p&gt;
&lt;p&gt;#######  Code starts here #######&lt;br /&gt;
#!/usr/bin/perl&lt;/p&gt;
&lt;p&gt;$file1 = &quot;available.txt&quot;;   #my first database&lt;br /&gt;
$file2 = &quot;needed.txt&quot;;   # my 2nd database&lt;/p&gt;
&lt;p&gt;# load file 1 into an array&lt;br /&gt;
open(FILE1,&quot;&amp;lt;$file1&quot;);&lt;br /&gt;
@file1 = ;&lt;br /&gt;
$num_lines1 = @file1;&lt;br /&gt;
# loop through lines in file 1&lt;br /&gt;
$i=0;&lt;br /&gt;
for ($x=0;$x&amp;lt;$num_lines;$x++) {&lt;br /&gt;
    @pieces1 = split(&quot;|&quot;,$line1);&lt;br /&gt;
    foreach $thing (@pieces1) {&lt;br /&gt;
        @arrFile1[$i] = array($x, $thing);&lt;br /&gt;
        $i++;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
close(FILE1);   # array containing file 1 is called @arrFile1&lt;/p&gt;
&lt;p&gt;# load file 2 into an array&lt;br /&gt;
open(FILE2,&quot;&amp;lt;$file2&quot;);&lt;br /&gt;
@file2 = ;&lt;br /&gt;
$num_lines2 = @file2;&lt;br /&gt;
# loop through lines in file 2&lt;br /&gt;
$i=0;&lt;br /&gt;
for ($y=0;$y&amp;lt;$num_lines2;$y++) {&lt;br /&gt;
    @pieces2 = split(&quot;|&quot;,$line);&lt;br /&gt;
    foreach $thing (@pieces2) {&lt;br /&gt;
        @arrFile2[$i] = array($y, $thing);&lt;br /&gt;
        $i++;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
close(FILE2);   # array containing file2 is called @arrFile2&lt;/p&gt;
&lt;p&gt;$num_fields1 = @arrFile1;   #counts number of elements in array 1&lt;br /&gt;
$num_fields2 = @arrFile2;  # counts number of elements in array 2 (at present, both these are &quot;0&quot;)&lt;/p&gt;
&lt;p&gt;for ($x=0;$x&amp;lt;$num_fields1;$x++) {&lt;br /&gt;
    for ($y=0;$y&amp;lt;$num_fields2;$y++) {  # conditions of the for loop&lt;br /&gt;
        if ($arrFile1[$x][1] == $arrFile1[$x][1]) {&lt;br /&gt;
            $arrResult[$x][0] = $arrFile1[$x][0];&lt;br /&gt;
            $arrResult[$x][1] = $arrFile1[$x][1];&lt;br /&gt;
            $arrResult[$x][2] = $arrFile2[$y][0];&lt;br /&gt;
        } #END if  # I don&#039;t fully understand what&#039;s happened in the &quot;if&quot; statement&lt;br /&gt;
        $intMatches = $intMatches + 1;&lt;br /&gt;
    } #END for 2&lt;br /&gt;
    $arrMatches[$x][0] = $arrFile2[$y][0];&lt;br /&gt;
    $arrMatches[$x][1] = $intMatches;&lt;br /&gt;
    $intMatches = 0;&lt;br /&gt;
} #END for 1&lt;/p&gt;
&lt;p&gt;print &quot;Content-type: text/html&quot;, &quot;\n\n&quot;;&lt;br /&gt;
print &quot;$num_lines1$num_lines2$num_fields1$num_fields2\n&quot;;&lt;br /&gt;
foreach $line (@arrMatches) {&lt;br /&gt;
print &quot;$line\n\n&quot;;&lt;br /&gt;
}&lt;br /&gt;
print &quot;$intMatches\n&quot;;&lt;/p&gt;
 </description>
     <pubDate>Wed, 17 Oct 2001 03:05:18 +0000</pubDate>
 <dc:creator>rline</dc:creator>
 <guid isPermaLink="false">comment 1091716 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/comparing-fields-1-database-fields-another#comment-1091682</link>
    <description> &lt;p&gt;I&#039;ll bet he&#039;s using Perl.. since that&#039;s where I&#039;ve seen the most flat file databases.&lt;/p&gt;
&lt;p&gt;I&#039;ll assume the flat file is like this:&lt;br /&gt;
fieldOne|fieldTwo|fieldThree|fieldFour&lt;br /&gt;
fieldOne|fieldTwo|fieldThree|fieldFour &lt;/p&gt;
&lt;p&gt;Been a while since I&#039;ve done much perl, but here&#039;s my interpretation of Peter&#039;s code into perl.&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;# load file 1 into an array&lt;br /&gt;open(FILE1,&amp;quot;&amp;lt;$file&amp;quot;);&lt;br /&gt;@file = &amp;lt;FILE1&amp;gt;;&lt;br /&gt;$num_lines = @file1;&lt;br /&gt;# loop through lines in file 1&lt;br /&gt;$i=0;&lt;br /&gt;for ($x=0;$x&amp;lt;$num_lines;$x++) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @pieces = split(&amp;quot;|&amp;quot;,$line1);&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach $thing (@pieces) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @arrFile1[$i] = array($x, $thing);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $i++;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;close(FILE1);&lt;br /&gt;&lt;br /&gt;# load file 2 into an array&lt;br /&gt;open(FILE2,&amp;quot;&amp;lt;$file&amp;quot;);&lt;br /&gt;@file = &amp;lt;FILE2&amp;gt;;&lt;br /&gt;$num_lines = @file1;&lt;br /&gt;# loop through lines in file 1&lt;br /&gt;$i=0;&lt;br /&gt;for ($x=0;$x&amp;lt;$num_lines;$x++) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @pieces = split(&amp;quot;|&amp;quot;,$line);&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach $thing (@pieces) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @arrFile2[$i] = array($x, $thing);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $i++;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;close(FILE2);&lt;br /&gt;&lt;br /&gt;$num_fileds1 = @arrFile1;&lt;br /&gt;$num_fileds2 = @arrFile2;&lt;br /&gt;&lt;br /&gt;for ($x=0;$x&amp;lt;$num_fileds1;$x++) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for ($y=0;$y&amp;lt;$num_fileds2;$y++) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($arrFile1[$x][1] == $arrFile1[$x][1]) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $arrResult[$x][0] = $arrFile1[$x][0];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $arrResult[$x][1] = $arrFile1[$x][1]; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $arrResult[$x][2] = $arrFile2[$y][0]; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } #END if&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $intMatches = $intMatches + 1; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } #END for 2 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $arrMatches[$x][0] = $arrFile2[$y][0]; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $arrMatches[$x][1] = $intMatches; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $intMatches = 0; &lt;br /&gt;} #END for 1&lt;/code&gt;&lt;/div&gt;&#039;&lt;br /&gt;
Not tested, and probably full of errors...&lt;/p&gt;
 </description>
     <pubDate>Tue, 16 Oct 2001 16:25:36 +0000</pubDate>
 <dc:creator>Mark Hensler</dc:creator>
 <guid isPermaLink="false">comment 1091682 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/comparing-fields-1-database-fields-another#comment-1091671</link>
    <description> &lt;p&gt;Comparing data in 2 flat file databases? I hope you&#039;re not expecting great performance! You didn&#039;t say what server you&#039;re on, so I&#039;ll use what I&#039;m most comfortable with (ASP). The best way I can think of doing it would be to open the flat files using FSO, then read each line into an array. For example, let&#039;s say your flat file is like this:&lt;/p&gt;
&lt;p&gt;fieldOne, fieldTwo, fieldThree, fieldFour&lt;br /&gt;
fieldOne, fieldTwo, fieldThree, fieldFour&lt;/p&gt;
&lt;p&gt;As you&#039;re looping through the file you need to pass these values to a 2 dimensional array like:&lt;/p&gt;
&lt;p&gt;arrFile1(x,0) = 1 &#039;line number&lt;br /&gt;
arrFile1(x,1) = FieldValue&lt;/p&gt;
&lt;p&gt;Then do the same thing with file 2:&lt;/p&gt;
&lt;p&gt;arrFile2(x,0) = 1 &#039;line number&lt;br /&gt;
arrFile2(x,1) = FieldValue&lt;/p&gt;
&lt;p&gt;Once you&#039;ve got the data in arrays, you can do whatever you want with it. For example:&lt;/p&gt;
&lt;p&gt;For x = LBound(arrFile1) To UBound(arrFile1)&lt;br /&gt;
  For y = LBound(arrFile2) To UBound(arrFile2)&lt;br /&gt;
     If arrFile1(x,1) = arrFile2(y,1) Then&lt;br /&gt;
        arrResult(x,0) = arrFile1(x,0)&lt;br /&gt;
        arrResult(x,1) = arrFile1(x,1)&lt;br /&gt;
        arrResult(x,2) = arrFile2(y,0)&lt;br /&gt;
     End If&lt;br /&gt;
     intMatches = intMatches + 1&lt;br /&gt;
  Next&lt;br /&gt;
  arrMatches(x,0) = arrFile2(y,0)&lt;br /&gt;
  arrMatches(x,1) = intMatches&lt;br /&gt;
  intMatches = 0&lt;br /&gt;
Next&lt;/p&gt;
&lt;p&gt;So, arrResult would hold all matches in the following way:&lt;/p&gt;
&lt;p&gt;arrResult(x,0) holds the line number from File1&lt;br /&gt;
arrResult(x,1) holds the value that was matched&lt;br /&gt;
arrResult(x,2) holds the line number from File2&lt;/p&gt;
&lt;p&gt;Then by looping through that array you get the search results. If it&#039;s empty or doesn&#039;t exist then there were no results.&lt;/p&gt;
&lt;p&gt;The number of matches per line is held in the arrMatches array. Hopefully this can point you in the right direction?&lt;/p&gt;
 </description>
     <pubDate>Tue, 16 Oct 2001 13:32:28 +0000</pubDate>
 <dc:creator>Peter J. Boettcher</dc:creator>
 <guid isPermaLink="false">comment 1091671 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
