sk35 has asked for the wisdom of the Perl Monks concerning the following question:
im having 2 files . i want to compare contents line by line and delete the matching ones. im able to do that with the below section. my issue is if i use a wild card in 1 file to match mulitple lines in second file , im not able to delete mulpitple matches
use strict; use warnings; $\="\n"; open my $fh1, '<', 'file1' or die $!; open my $fh2, '<', 'file2' or die $!; open my $out, '>', 'file1minusfile2' or die $!; chomp(my @arr1=<$fh1>); chomp(my @arr2=<$fh2>); foreach my $x (@arr1){ print $out $x if (!grep (/^\Q$x\E$/,@arr2)); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: compare contents of 2 file having wildcards
by choroba (Cardinal) on May 19, 2016 at 11:41 UTC | |
|
Re: compare contents of 2 file having wildcards
by Laurent_R (Canon) on May 19, 2016 at 11:42 UTC | |
|
Re: compare contents of 2 file having wildcards
by Anonymous Monk on May 19, 2016 at 11:41 UTC |