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
In reply to Re: Why is the following instance of Matching using an array element not working
by kcott
in thread Why is the following instance of Matching using an array element not working
by MyJeweledPerls
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |