All pastes #1322405 Raw Edit

CSV Diff

public text v1 · immutable
#1322405 ·published 2009-01-30 02:43 UTC
rendered paste body
#!/usr/bin/perl

$filea = $ARGV[0];
$fileb = $ARGV[1];

open(A, $filea);
open(B, $fileb);

$time_now = time();

open(OLD, ">del.csv");
open(NEW, ">add.csv");
while (!($eof_a && $eof_b))
{
        $i++;

        unless ($a = <A>) { $eof_a = 1; }
        chomp($a);

        unless ($b = <B>) { $eof_b = 1; }
        chomp($b);

        while (($a ne $b) && (!$eof_a) && (!$eof_b))
        {
                if ($a lt $b)
                {
                        print OLD $a."\n";

                        unless ($a = <A>) { $eof_a = 1; }
                        chomp($a);
                }

                if ($a gt $b)
                {
                        print NEW $b."\n";

                        unless ($b = <B>) { $eof_b = 1; }
                        chomp($b);
                }
        }

        if (time() > $time_now)
        {
                $time_now = time();
                print $i."\n";
                $i = 0;
        }
}
close(OLD);
close(NEW);