in reply to Re: list lines not found in config (while+if)
in thread list lines not found in config (while+if)
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>;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: list lines not found in config (while+if)
by Marshall (Canon) on Apr 08, 2009 at 02:48 UTC | |
by GrandFather (Saint) on Apr 08, 2009 at 03:28 UTC | |
by Marshall (Canon) on Apr 08, 2009 at 04:43 UTC |