Is there a better way to compare large files than this snippet, which runs out of 
memory if files > 30mb. 

It is also slow, about the same speed as comparing in a text editor!

Thank you.

__SNIP__

@file1 =  (<IN1>);
@file2 =  (<IN2>);
$are_equal = compare_arrays(\@file1, \@file2);

if ($are_equal) {

print "Files are IDENTICAL \n";
}

else

{

print "Files are DIFFERENT \n";
}

    sub compare_arrays {
               my ($first, $second) = @_;
               #no warnings;  # silence spurious -w undef complaints
               return 0 unless @$first == @$second;
               for (my $i = 0; $i < @$first; $i++) {
                   return 0 if $first->[$i] ne $second->[$i];
               }
               return 1;
           }

__SNIP__

Regards,

Mark

Surrey,UK




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to