in reply to comparing 2 columns
This should do what you want:
#!/usr/bin/perl # http://perlmonks.org/?node_id=1151834 use strict; use warnings; open my $FH1, '<', shift or die $!; my %keys; while (<$FH1>) { chomp; $keys{$_}++; } close $FH1; open my $FH2, '<', shift or die $!; while (<$FH2>) { chomp; my ($record, $key) = split ',', $_, 2; print "match: $key record: $record\n" if exists $keys{$key}; } close $FH2;
Your code looks like something you've copied from somewhere without really understanding it. I'd advise against doing that: cargo cult code like that might be inefficient, might not actually do what you want, or it might even do damage to your system or data without you knowing it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: comparing 2 columns
by 2015_newbie (Novice) on Jan 05, 2016 at 05:09 UTC | |
by AnomalousMonk (Archbishop) on Jan 05, 2016 at 05:29 UTC |