1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| #!/usr/bin/perl
use strict;
use warnings;
use feature qw(:5.10);
open (EXTRACTION, ">Compar_$ARGV[0]_$ARGV[1].log") || die ("Vous ne pouvez pas créer le fichier \"Comp_$ARGV[0]_$ARGV[1].log\"");
my $max_size;
sub cmp_big($$$) {
my ($f1, $f2, $f2_info) = @_;
open my $F1, "<", $f1 or die "Cant open $f1";
my $F1_line_count=0;
my $file2Conc = "XXXXXXXXXXXXXXXX";
open F1, $ARGV[0] or die $!;
while (<F1>) {
$F1_line_count ++;
}
close (F1);
say EXTRACTION "Loading $f1";
while (!eof $F1) {
my %F1;
while (keys %F1 < $max_size && defined(my $l1 = <$F1>)) {
chomp($l1);
$F1{$l1}++;
}
print "Memory exhausted at line $./$F1_line_count => start comparing\n";
open my $F2, "<", $f2 or die "Cant open $f2";
while (my $l2 = <$F2>) {
chomp $l2;
if (exists $F1{$l2}) {
delete $F1{$l2} if --$F1{$l2} == 0;
}
}
say EXTRACTION "[$_] not present in $f2_info $f2 ($F1{$_})" foreach keys %F1;
say "Continue loading $f1";
}
}
$max_size = $ARGV[2] // 1000000;
cmp_big($ARGV[0], $ARGV[1], "2nd file");
cmp_big($ARGV[1], $ARGV[0], "1rst file");
close (EXTRACTION); |
Partager