forked from hmw3/Tips_and_Hacks
54 lines
1.1 KiB
Perl
54 lines
1.1 KiB
Perl
use 5.12.0;
|
|
use File::Slurp;
|
|
use File::Find ;
|
|
use FindBin '$Bin';
|
|
use Cwd ;
|
|
use utf8;
|
|
#use open IN => ":utf8", OUT => ":utf8";
|
|
use open IO => ":utf8";
|
|
$" = "\n";
|
|
|
|
my ($pwd, $d) = (cwd(), "\\");
|
|
if ($^O eq "darwin" || $^O eq "linux") {$d = "/"}
|
|
|
|
open LOG, ">$Bin${d}Logs${d}log.log" or die "$Bin${d}Logs${d}log.log: $!";
|
|
|
|
my (@consistent_delete_files) = ("$Bin${d}Exceptions${d}Consistent_Deletes.NT.txt", "$Bin${d}Exceptions${d}Consistent_Deletes.OT.txt");
|
|
|
|
foreach my $this_cd_file (@consistent_delete_files) {
|
|
|
|
my %numbers;
|
|
my (@array, @sorted_array);
|
|
|
|
say $this_cd_file;
|
|
|
|
open (my $file, "<:utf8", $this_cd_file) or die "$this_cd_file:\n$!";
|
|
|
|
while (my $line = <$file>) {
|
|
chomp $line;
|
|
$numbers{$line} = $line unless (exists $numbers{$line})
|
|
}
|
|
|
|
close $file;
|
|
|
|
foreach my $this_no (sort keys %numbers) {
|
|
push @array, $this_no
|
|
}
|
|
|
|
say LOG "@array\n\n==\n\n";
|
|
|
|
@sorted_array = sort {$a <=> $b} @array;
|
|
|
|
say LOG "@sorted_array\n\n====\n\n";
|
|
|
|
open(OUT, ">$this_cd_file") or die "$file";
|
|
|
|
say OUT "@sorted_array";
|
|
|
|
close "$this_cd_file";
|
|
|
|
}
|
|
|
|
close LOG;
|
|
|
|
say "Done." |