test.txt foo bar baz
texty_as_all_beat_hell.tst foo bar baz
ffoo.txt test bar baz
1140904.txt bar baz bat
####
1140904a.txt foo bar baz
texty_as_all_beat_hell.tst foo bar baz
ffoo.txt test bar baz
baz.test bar blivitz
####
#!/usr/bin/perl
use 5.018;
use strict; # LET PERL HELP YOU (id typos, etc)
use warnings; # LET PERL HELP YOU (id typos, etc): strict and warnings, always!
use Data::Dumper;
# print "Enter name for first file: ";
my $file1 = 'C:\_ww\1140904.txt';
# print "Enter name for second file: ";
my $file2 = '1140904a.txt';
my (@fileONE, $fileONE);
open(my $FH, "<", $file1) || die "Can't open $file1: $!\n";
for my $line(<$FH>) {
chomp $line;
say "DEBUG Ln 18: \$line is: $line";
my ($col1) = split(/ /, $line, 2);
push @fileONE, $col1;
next;
}
say Dumper @fileONE;
say "\n\t --------";
my (@fileTWO, $FH2);
open($FH2, "<", $file2) || die "Can't open $file2: $!\n";
for my $line2(<$FH2>) {
chomp $line2;
say "DEBUG Ln 34: \$line2 is: $line2";
my ($col1_2) = split(/ /, $line2);
push @fileTWO, $col1_2;
next;
}
say "DEBUG Ln 37 - reached Ln 37";
say Dumper @fileTWO;
say "\n **************";
my ($fileTWO, $i);
for ($i = 0; $i < @fileONE; ++$i) {
my $BASEname1 = 'fileONE[$';
my $Fname1 = '$' . $BASEname1 . "$i" . ']';
my $BASENAME2 = 'fileTWO[$';
my $Fname2 = '$' . $BASENAME2 . $i . ']';
my $content1 = $fileONE[$i];
my $content2 = $fileTWO[$i];
# say "DEBUG Ln50: content of \$Fname1:\t $fileONE[$i] \n\t and content of \$Fname2: $fileTWO[$i] \n";
if ($content1 eq $content2 ) {
say "Exclude because it's a match: |--> $content2 <--| \n";
} else {
say "\t Content of $Fname1 and $Fname2 does not match.\n";
}
}
####
Content of $fileONE[$0] and $fileTWO[$0] does not match.
Exclude because it's a match: |--> texty_as_all_beat_hell.tst <--|
Exclude because it's a match: |--> ffoo.txt <--|
Content of $fileONE[$3] and $fileTWO[$3] does not match.