I have two files. File1 contains a list of items that I want to remove if found in file 2.
File1: Yellow Red Blue
File2: Orange Pink Purple Blue
I would like the results of file 2 to be Orange Pink Purple as Blue is in the first file, it should be removed.
Could anyone give some advice as why the logic in my code is not working?
File1: Yellow Red Blue
File2: Orange Pink Purple Blue
I would like the results of file 2 to be Orange Pink Purple as Blue is in the first file, it should be removed.
Could anyone give some advice as why the logic in my code is not working?
Code:
tie my @file_lines, 'Tie::File', $File2 or die;
open(MYINPUTFILE, '<' ,"$File1");
foreach my $line (<MYINPUTFILE>) {
chomp ($line);
@file_lines = grep /^"$line"/, @file_lines;
untie @file_lines or die "$!";
}
Comment