<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using perl to compare large lists ... in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726075#M99643</link>
    <description>I work with Daniel and I think I cooked up an answer.  I'm posting it for 2 reasons:&lt;BR /&gt;&lt;BR /&gt;1) To make sure my logic is correct.&lt;BR /&gt;&lt;BR /&gt;2) For posterity.  I dredged many an archive for something similar with no luck.&lt;BR /&gt;&lt;BR /&gt;I didn't see the 'tie' suggestion before doing this, so I'm not sure how my solution compares.  The size of the lists are 14 million each, so I wanted to go through each file as few times as possible.  My code goes through each file once, but the inputs must be sorted.  It steps through each file one line at a time and does an alphanumeric comparison. If they are the same, the line is put in the 'in_both' file.  If the line from 0 is less than the line from 1, it must not be in file 1, so itâ  s put in the 'in_0_only' and vice versa. Run time was 3-7 minutes.&lt;BR /&gt;&lt;BR /&gt;---(Preliminary stuff)&lt;BR /&gt;# Churn, baby, churn.&lt;BR /&gt;#---------------&lt;BR /&gt;&lt;BR /&gt;# Read first lines.&lt;BR /&gt;unless ( defined($record0 = &lt;FILE0&gt; ) ) { die "ERROR: $ARGV[0] is empty.\n"; }&lt;BR /&gt;unless ( defined($record1 = &lt;FILE1&gt; ) ) { die "ERROR: $ARGV[1] is empty.\n"; }&lt;BR /&gt;&lt;BR /&gt;while ( $eof0 == 0 &amp;amp;&amp;amp; $eof1 == 0 )&lt;BR /&gt;{&lt;BR /&gt;        $need_next0 = 0 ;&lt;BR /&gt;        $need_next1 = 0 ;&lt;BR /&gt;&lt;BR /&gt;        if ( $record0 eq $record1 )&lt;BR /&gt;        {&lt;BR /&gt;                print INBOTH $record0 ;&lt;BR /&gt;                $need_next0 = 1 ;&lt;BR /&gt;                $need_next1 = 1 ;&lt;BR /&gt;        } else {&lt;BR /&gt;                if ( $record0 lt $record1 )&lt;BR /&gt;                {&lt;BR /&gt;                        print INFILE0 $record0 ;&lt;BR /&gt;                        $need_next0 = 1;&lt;BR /&gt;                } else {&lt;BR /&gt;                        print INFILE1 $record1 ;&lt;BR /&gt;                        $need_next1 = 1;&lt;BR /&gt;                }&lt;BR /&gt;        }&lt;BR /&gt;&lt;BR /&gt;        if ( $need_next0 == 1 )&lt;BR /&gt;            { unless ( defined($record0 = &lt;FILE0&gt; ) ) { $eof0 = 1; } }&lt;BR /&gt;        if ( $need_next1 == 1 )&lt;BR /&gt;            { unless ( defined($record1 = &lt;FILE1&gt; ) ) { $eof1 = 1; } }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;# Cleanup the rest of the file.&lt;BR /&gt;#---------------&lt;BR /&gt;until ( $eof0 == 1 )&lt;BR /&gt;{&lt;BR /&gt;        print INFILE0 $record0 ;&lt;BR /&gt;        unless ( defined($record0 = &lt;FILE0&gt; ) ) { $eof0 = 1; }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;until ( $eof1 == 1 )&lt;BR /&gt;{&lt;BR /&gt;        print INFILE1 $record1 ;&lt;BR /&gt;        unless ( defined($record1 = &lt;FILE1&gt; ) ) { $eof1 = 1; }&lt;BR /&gt;}&lt;BR /&gt;---&lt;/FILE1&gt;&lt;/FILE0&gt;&lt;/FILE1&gt;&lt;/FILE0&gt;&lt;/FILE1&gt;&lt;/FILE0&gt;</description>
    <pubDate>Wed, 22 Feb 2006 10:25:34 GMT</pubDate>
    <dc:creator>Steven M Evans</dc:creator>
    <dc:date>2006-02-22T10:25:34Z</dc:date>
    <item>
      <title>Using perl to compare large lists ...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726063#M99631</link>
      <description>Hi, folks.&lt;BR /&gt;&lt;BR /&gt;Against large files, I get "Out of memory!" using the code below.  The basic idea is, I want the items in list A which are not in list B for very large lists.  Are there options outside of breaking down the files into smaller chunks?&lt;BR /&gt;&lt;BR /&gt;Thanks, all.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl -w&lt;BR /&gt;&lt;BR /&gt;open (FILE0,$ARGV[0]) || die "Problem with $ARGV[0]\n";&lt;BR /&gt;open (FILE1,$ARGV[1]) || die "Problem with $ARGV[1]\n";&lt;BR /&gt;&lt;BR /&gt;while ( defined($item0=&lt;FILE0&gt;) )&lt;BR /&gt;{&lt;BR /&gt;        seek FILE1, 0, 0;&lt;BR /&gt;        @x=grep { /$item0/ } &lt;FILE1&gt;;&lt;BR /&gt;        if ( $#x != 0 ) { print $item0 } # For items in argv0, but not in argv1.&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;close (FILE1);&lt;BR /&gt;close (FILE0);&lt;/FILE1&gt;&lt;/FILE0&gt;</description>
      <pubDate>Tue, 07 Feb 2006 08:59:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726063#M99631</guid>
      <dc:creator>A. Daniel King_1</dc:creator>
      <dc:date>2006-02-07T08:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: Using perl to compare large lists ...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726064#M99632</link>
      <description>Open the smallest file first, put it in a hash, and use that when traversing the large file&lt;BR /&gt;&lt;BR /&gt;If the small file is still too large, use a tied hash&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;&lt;BR /&gt;my $f1 = shift or die "usage: $0 file1 file ...\n";&lt;BR /&gt;open my $f, "&amp;lt; $f1" or die "$f1: $!\n";&lt;BR /&gt;tie my %f1, "DB_File", "/tmp/keys$$";&lt;BR /&gt;while (&amp;lt;$f&amp;gt;) {&lt;BR /&gt; $f1{$_}++;&lt;BR /&gt; }&lt;BR /&gt;while (&amp;lt;&amp;gt;) { # The rest of the files&lt;BR /&gt;if (exists $f1{$_} {&lt;BR /&gt;# This line is also in file0&lt;BR /&gt;}&lt;BR /&gt;else {&lt;BR /&gt;# This is not&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;untie %f1;&lt;BR /&gt;unlink "/tmp/keys$$";&lt;BR /&gt;--&amp;gt;8---&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Tue, 07 Feb 2006 09:10:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726064#M99632</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-02-07T09:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using perl to compare large lists ...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726065#M99633</link>
      <description>Hi Daniel:&lt;BR /&gt;&lt;BR /&gt;Perhaps, instead of building a list whose elements are the full record, you could build a hash of the keys to the records you want to report.  Then, walk the hash and print the items of interest using the keys to seek the full record.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 07 Feb 2006 09:16:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726065#M99633</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-02-07T09:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using perl to compare large lists ...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726066#M99634</link>
      <description>Hi,&lt;BR /&gt;not a perl reply, but did you have a look at "comm" ?&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Feb 2006 09:20:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726066#M99634</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-02-07T09:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using perl to compare large lists ...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726067#M99635</link>
      <description>warning: though comm (and join) are great for this, they need sorted input files!&lt;BR /&gt;That is often a limitation in real life problems&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Tue, 07 Feb 2006 09:25:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726067#M99635</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-02-07T09:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: Using perl to compare large lists ...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726068#M99636</link>
      <description>Hello, &lt;BR /&gt;&lt;BR /&gt;Check this link, it could be helpful&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.codecomments.com/archive234-2005-5-497414.html" target="_blank"&gt;http://www.codecomments.com/archive234-2005-5-497414.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;-Arun</description>
      <pubDate>Tue, 07 Feb 2006 11:35:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726068#M99636</guid>
      <dc:creator>Arunvijai_4</dc:creator>
      <dc:date>2006-02-07T11:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using perl to compare large lists ...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726069#M99637</link>
      <description>Hi,&lt;BR /&gt;why not use:&lt;BR /&gt;grep -vf small_file big file&lt;BR /&gt;&lt;BR /&gt;of course file have to be sorted.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art</description>
      <pubDate>Wed, 08 Feb 2006 04:30:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726069#M99637</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2006-02-08T04:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using perl to compare large lists ...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726070#M99638</link>
      <description>A good attempt ...&lt;BR /&gt;&lt;BR /&gt;grep: not enough memory</description>
      <pubDate>Mon, 13 Feb 2006 12:40:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726070#M99638</guid>
      <dc:creator>A. Daniel King_1</dc:creator>
      <dc:date>2006-02-13T12:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: Using perl to compare large lists ...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726071#M99639</link>
      <description>Did you try my first suggestion?&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Mon, 13 Feb 2006 13:04:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726071#M99639</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-02-13T13:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using perl to compare large lists ...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726072#M99640</link>
      <description>Just thinking aloud...&lt;BR /&gt;&lt;BR /&gt;First, Did you try Merijn's first suggestion? I see no 'points' to indicate a usefulness for the answer.&lt;BR /&gt;&lt;BR /&gt;Secondly, is this a once-in-a-lifetime-never-mind-the-processing-time cleanup, or a job to be scheduled frequently?&lt;BR /&gt;&lt;BR /&gt;Third, Really large lists don't just happen.&lt;BR /&gt;They have some meaing, often order, often some key, some 'objectness' or record size. &lt;BR /&gt;If you describe that to us, then we may be able to help better.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;For example, you may be able to build an array of key values and seek addresses such as not to store the whole 'records/blobs' and then later go back.&lt;BR /&gt;&lt;BR /&gt;If they are sorted you can do a classic some from the left, some from the right compare. See below.&lt;BR /&gt;&lt;BR /&gt;How much difference do you expect, is still useful to report?&lt;BR /&gt;&lt;BR /&gt;How about not breaking down the actual list in chunks, but just the processing?&lt;BR /&gt;Some algoritme where you read in N records (100,000?) from one file, then start reading the other file and deleting matches untill less then M matches (10,000?).&lt;BR /&gt;Now read N-M more from the first file, and continue reading from where you were the second file, or re-start the second file from the start untill again dowm below M matches. Repeat untill at end of first file.&lt;BR /&gt;When at at, make one more sweep from second file. Admittedly this is a lot of handwaving, but something along those lines, the details heavily depending on what you know about the files.&lt;BR /&gt;&lt;BR /&gt;Below you'll find a script I made and used to walk two largish parameter value list I needed to compare and report on. This is a case where I knew the params were sorted by a key. So I split the lines from f1 and f2 into their keys k1 and k2 and values v1 and v2. The compare k1 and k2. If equal compare values v1 and v2 and report. If k1&lt;K2 then="" read="" next="" f1.="" if="" k1=""&gt;k2 then read next f2&lt;BR /&gt;&lt;BR /&gt;The actual script below is probably not useful (unless you are comparing SAP benchmark r3.out files ;-), but the principle may become clearer reading it. (then again, the added processing like 'known to be variable' substitutions' and pretty-printing may confuse the concept beyond recognition :^)&lt;BR /&gt;&lt;BR /&gt;Hope this helps some,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/bin/perl&lt;BR /&gt;#&lt;BR /&gt;$f1 = @ARGV[0];&lt;BR /&gt;$f2 = @ARGV[1];&lt;BR /&gt;$ALL = @ARGV[2];&lt;BR /&gt;die "Must provide two R3.out files to compare" unless $f2; open (F1, $f1) || die "Error open file 1: $f1"; open (F2, $f2) || die "Error open file 2: $f2";&lt;BR /&gt;&lt;BR /&gt;# Find system ID and first parameter&lt;BR /&gt;while (&lt;F1&gt;) {&lt;BR /&gt;  $S1 = $1 if (/SAP System\s+(\w+)\s/);&lt;BR /&gt;  $I1 = $1 if (/^INSTANCE_NAME\s+\(!\) (\w+)/);&lt;BR /&gt;  last if (/^Param/);&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;while (&lt;F2&gt;) {&lt;BR /&gt;  $S2 = $1 if (/SAP System\s+(\w+)\s/);&lt;BR /&gt;  $I2 = $1 if (/^INSTANCE_NAME\s+\(!\) (\w+)/);&lt;BR /&gt;  last if (/^Param/);&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;$format = "%-30.30s %s %-20s %s %-20s\n"; print "\nColumn \"?\" legend: \"|\" = default, \"X\" = changed, \" \" = missing.\n\n"; printf $format, "Parameter", " ", "$S1 - $I1", " ", "$S2 - $I2"; printf $format, "------------------------------","?","--------------------",&lt;BR /&gt;                            "?","--------------------"; while (&lt;F1&gt;) {&lt;BR /&gt;  $v1 = " ";&lt;BR /&gt;  if (/^(\S+).*(   |\(!\)) (.{1,20})/) {&lt;BR /&gt;    $k1 = $1;&lt;BR /&gt;    $d1 = ($2 eq "   ") ? "|" : "X";&lt;BR /&gt;    $v1 = $3;&lt;BR /&gt;    $v1 =~ s/$S1/{SID}/g;&lt;BR /&gt;    $v1 =~ s/$I1/{INST}/g;&lt;BR /&gt;    }&lt;BR /&gt;  while ($k2 lt $k1) {&lt;BR /&gt;    last unless ($_ = &lt;F2&gt;);&lt;BR /&gt;    $v2 = " ";&lt;BR /&gt;    if (/^(\S+).*(   |\(!\)) (.{1,20})/) {&lt;BR /&gt;      $k2 = $1;&lt;BR /&gt;      $d2 = ($2 eq "   ") ? "|" : "X";&lt;BR /&gt;      $v2 = $3;&lt;BR /&gt;      $v2 =~ s/$S2/{SID}/g;&lt;BR /&gt;      $v2 =~ s/$I2/{INST}/g;&lt;BR /&gt;      }&lt;BR /&gt;    if ($k2 lt $k1) {&lt;BR /&gt;      printf $format, $k2, " ", " ", $d2, $v2;&lt;BR /&gt;      }&lt;BR /&gt;    }&lt;BR /&gt;  if ($k1 eq $k2) {&lt;BR /&gt;    printf $format, $k1, $d1, $v1, $d2, $v2 if&lt;BR /&gt;           ($ALL || ($v1 ne $v2 &amp;amp;&amp;amp; ($d1.$d2 ne "||") ) );&lt;BR /&gt;    } else {&lt;BR /&gt;    printf $format, $k1, $d1, $v1, " ", " ";&lt;BR /&gt;    }&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Sample output&lt;BR /&gt;Column "?" legend: "|" = default, "X" = changed, " " = missing.&lt;BR /&gt;&lt;BR /&gt;Parameter                        BE2 - D11              RAC - D02&lt;BR /&gt;------------------------------ ? -------------------- ? --------------------&lt;BR /&gt;DIR_ORAHOME                    | /oracle/{SID}        X /oracle/{SID}/901_64&lt;BR /&gt;ES/SHM_MAX_PRIV_SEGS           X 63                   | 2&lt;BR /&gt;ES/TABLE                       X SHM_SEGS             | UNIX_STD&lt;BR /&gt;SAPDBHOST                      X b009                 X sapsd&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/F2&gt;&lt;/F1&gt;&lt;/F2&gt;&lt;/F1&gt;&lt;/K2&gt;</description>
      <pubDate>Mon, 13 Feb 2006 13:26:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726072#M99640</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-02-13T13:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using perl to compare large lists ...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726073#M99641</link>
      <description>I've not yet installed the module which will give me "tie" ... and will award points as I evaluate the answers ...</description>
      <pubDate>Mon, 13 Feb 2006 14:26:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726073#M99641</guid>
      <dc:creator>A. Daniel King_1</dc:creator>
      <dc:date>2006-02-13T14:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: Using perl to compare large lists ...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726074#M99642</link>
      <description>"tie" is no `module'. It's a standard perl builtin mechanism.&lt;BR /&gt;&lt;BR /&gt;"DB_File" is a module, but it comes with the CORE perl distribution, so whatever build you use, should support it.&lt;BR /&gt;&lt;BR /&gt;# perldoc -f tie&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Mon, 13 Feb 2006 16:47:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726074#M99642</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-02-13T16:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using perl to compare large lists ...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726075#M99643</link>
      <description>I work with Daniel and I think I cooked up an answer.  I'm posting it for 2 reasons:&lt;BR /&gt;&lt;BR /&gt;1) To make sure my logic is correct.&lt;BR /&gt;&lt;BR /&gt;2) For posterity.  I dredged many an archive for something similar with no luck.&lt;BR /&gt;&lt;BR /&gt;I didn't see the 'tie' suggestion before doing this, so I'm not sure how my solution compares.  The size of the lists are 14 million each, so I wanted to go through each file as few times as possible.  My code goes through each file once, but the inputs must be sorted.  It steps through each file one line at a time and does an alphanumeric comparison. If they are the same, the line is put in the 'in_both' file.  If the line from 0 is less than the line from 1, it must not be in file 1, so itâ  s put in the 'in_0_only' and vice versa. Run time was 3-7 minutes.&lt;BR /&gt;&lt;BR /&gt;---(Preliminary stuff)&lt;BR /&gt;# Churn, baby, churn.&lt;BR /&gt;#---------------&lt;BR /&gt;&lt;BR /&gt;# Read first lines.&lt;BR /&gt;unless ( defined($record0 = &lt;FILE0&gt; ) ) { die "ERROR: $ARGV[0] is empty.\n"; }&lt;BR /&gt;unless ( defined($record1 = &lt;FILE1&gt; ) ) { die "ERROR: $ARGV[1] is empty.\n"; }&lt;BR /&gt;&lt;BR /&gt;while ( $eof0 == 0 &amp;amp;&amp;amp; $eof1 == 0 )&lt;BR /&gt;{&lt;BR /&gt;        $need_next0 = 0 ;&lt;BR /&gt;        $need_next1 = 0 ;&lt;BR /&gt;&lt;BR /&gt;        if ( $record0 eq $record1 )&lt;BR /&gt;        {&lt;BR /&gt;                print INBOTH $record0 ;&lt;BR /&gt;                $need_next0 = 1 ;&lt;BR /&gt;                $need_next1 = 1 ;&lt;BR /&gt;        } else {&lt;BR /&gt;                if ( $record0 lt $record1 )&lt;BR /&gt;                {&lt;BR /&gt;                        print INFILE0 $record0 ;&lt;BR /&gt;                        $need_next0 = 1;&lt;BR /&gt;                } else {&lt;BR /&gt;                        print INFILE1 $record1 ;&lt;BR /&gt;                        $need_next1 = 1;&lt;BR /&gt;                }&lt;BR /&gt;        }&lt;BR /&gt;&lt;BR /&gt;        if ( $need_next0 == 1 )&lt;BR /&gt;            { unless ( defined($record0 = &lt;FILE0&gt; ) ) { $eof0 = 1; } }&lt;BR /&gt;        if ( $need_next1 == 1 )&lt;BR /&gt;            { unless ( defined($record1 = &lt;FILE1&gt; ) ) { $eof1 = 1; } }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;# Cleanup the rest of the file.&lt;BR /&gt;#---------------&lt;BR /&gt;until ( $eof0 == 1 )&lt;BR /&gt;{&lt;BR /&gt;        print INFILE0 $record0 ;&lt;BR /&gt;        unless ( defined($record0 = &lt;FILE0&gt; ) ) { $eof0 = 1; }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;until ( $eof1 == 1 )&lt;BR /&gt;{&lt;BR /&gt;        print INFILE1 $record1 ;&lt;BR /&gt;        unless ( defined($record1 = &lt;FILE1&gt; ) ) { $eof1 = 1; }&lt;BR /&gt;}&lt;BR /&gt;---&lt;/FILE1&gt;&lt;/FILE0&gt;&lt;/FILE1&gt;&lt;/FILE0&gt;&lt;/FILE1&gt;&lt;/FILE0&gt;</description>
      <pubDate>Wed, 22 Feb 2006 10:25:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726075#M99643</guid>
      <dc:creator>Steven M Evans</dc:creator>
      <dc:date>2006-02-22T10:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using perl to compare large lists ...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726076#M99644</link>
      <description>It seems I need a good book on algorithms.&lt;BR /&gt;&lt;BR /&gt;Thanks, Steve, and everyone else who gave a shot!</description>
      <pubDate>Mon, 22 May 2006 12:54:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-perl-to-compare-large-lists/m-p/3726076#M99644</guid>
      <dc:creator>A. Daniel King_1</dc:creator>
      <dc:date>2006-05-22T12:54:02Z</dc:date>
    </item>
  </channel>
</rss>

