$ cat file1
1|2000-00-00|2010-02-02||
2| 00:00:00|2012-02-24||
3|2000-00-00|2011-02-02||
$ cat file2
2000-00-00
00:00:00
$ cat script.pl
use warnings;
use strict;
die qq[Usage: perl $0 <file-1> <file-2>\n] unless @ARGV == 2;
open my $fh1, qq[<], shift @ARGV or die qq[Cannot open input file\n];
open my $fh2, qq[<], shift @ARGV or die qq[Cannot open input file\n];
my (@patterns, $pattern, $re);
while ( <$fh2> ) {
next if m/\A\s*\Z/;
s/\A\s+/\\s*/;
s/\s+\Z/\\s*/;
push @patterns, $_;
}
$pattern = join qq[|], @patterns;
$re = qr/($pattern)/;
while ( <$fh1> ) {
do { print, next } if m/\A\s*\Z/;
chomp;
s/$re//go;
printf qq[%s\n], $_;
}
$ perl script.pl file1 file2
1||2010-02-02||
2||2012-02-24||
3||2011-02-02||