in reply to Why is the following instance of Matching using an array element not working
Without seeing any sample input, the following is just guesswork.
You're currently matching the entire record against the fourth ID; I think you want to match the fourth element of each record against all IDs.
I suspect
foreach my $records(@merged_array){ if($records =~ /$sample_ids[3]/){ print $records; } }
should probably be more like
foreach my $records (@merged_array) { my @elements = split /,/, $records; for my $sample_id (@sample_ids) { if ($elements[3] =~ /$sample_id/) { print $records; } } }
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why is the following instance of Matching using an array element not working
by MyJeweledPerls (Initiate) on Aug 10, 2012 at 19:19 UTC |