in reply to check 2 string arrays
Update: This detects BM_allocation_0 even when it is part of RCF_BM_allocation_0, but it is unclear what is required here.use strict; use warnings; my @array1 = qw (abc_RCF_BM_allocation_0_kl aplc_RCF_BM_allocation_0_in_nml fbe_RCF_BM_allocation_0_in_tvg ap_hu_BM_allocation_0_in_nml); my @array2 = qw(RCF_BM_allocation_0_in BM_allocation_0 RCF_BM_allocation_0); for my $pattern (@array2) { my @results = grep /$pattern/, @array1; print "$pattern is in @results\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: check 2 string arrays
by sharan (Acolyte) on Mar 31, 2009 at 13:21 UTC |