Note kennethk's comments regarding the two parameter open in his reply to the OP!
What kennethk forgot to mention was that you should use lexical file handles too.
open ... $filename || die makes for an unhappy life. || binds to $filename, not to the result of open as you may be hoping. $filename is true for all likely values so the die will never fire, regardless of what the result of the open is! Use open ... $filename or die instead. It's often helpful in the die to show the error message associated with the open failure using $OS_ERROR ($!).
Making those changes, removing extraneous () and minor adjusting of white space produces the following (untested) code:
#!/usr/bin/perl use strict; use warnings; die "Usage fileReference File2Check >outfile" if @ARGV != 2; my ($fileRef, $file2Check) = @ARGV; open my $fileREFIn, '<', $fileRef or die "unable to open $fileRef: $!" +; open my $fileCHKIn, '<', $file2Check or die "unable to open $file2Chec +k: $!"; my %seen = map { chomp; $_ => 1 } <$fileREFIn>; print grep {! $seen{(split /,/, $_)[0]}} <$fileCHKIn>;
In reply to Re^2: list lines not found in config (while+if)
by GrandFather
in thread list lines not found in config (while+if)
by tangledupinperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |