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
|
#!/usr/bin/perl
use strict;
use Carp;
use warnings;
my ($fichier_analyse, $fichier_conf, $fichier_focal) = ("analyse.txt", "conf.txt", "fichier.focal");
open (my $fh_conf, $fichier_conf) or die("impossible d'ouvrir le fichier $fichier_conf, $!\n");
my @data_temp;
my @fichier_conf = <$fh_conf>;
close($fh_conf);
# Lecture fichier analyse
open (my $fh_analyse, $fichier_analyse) or die("impossible d'ouvrir le fichier $fichier_analyse, $!\n");
while(my $ligne_analyse = <$fh_analyse>) {
chomp($ligne_analyse);
my $compt = 0;
# Lecture fichier conf
foreach my $ligne_conf (@fichier_conf) {
chomp($ligne_conf);
# comparaison
if($ligne_analyse =~ /$ligne_conf/i ) {
$compt ++;
last;
}
}
if($compt == 0) {
push (@data_temp, $ligne_analyse);
}
}
close($fh_analyse);
open (my $fh_focal, ">>$fichier_focal") or die("impossible d'ecrire dans le fichier $fichier_focal, $!\n");
open (my $fh_analyse2, ">$fichier_analyse") or die("impossible d'ecrire dans le fichier $fichier_analyse, $!\n");
foreach my $temp (sort @data_temp) {
print {$fh_focal} "$temp\n";
print {$fh_analyse2} "$temp\n";
}
close($fh_focal);
close($fh_analyse2); |
Partager