in reply to Re^2: My code sucks, please help me understand why.
in thread My code sucks, please help me understand why.
Since you can extract the IDs easily for each file, you can put the IDs from PIDS into a hash, and query that while iterating over FIDS:
my %ids; while (my $line = <PIDS>) { chomp $line; my (undef, $id) = split /\|/, $line; $ids{$id} = 1; } while (my $line = <FIDS>) { my ($id, $rest) = split /;/, $line, 2; if ($ids{$id}) { print "Found id '$id' in line $line"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: My code sucks, please help me understand why.
by mirage4d (Novice) on Oct 15, 2009 at 15:32 UTC | |
by moritz (Cardinal) on Oct 15, 2009 at 17:09 UTC |