Here is a more Perl-ish way to code this up:
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 $i (0 .. $#array1){ for my $j (0 .. $#array2){ if ($array1[$i] =~ /$array2[$j]/) { print "$array1[$i] contains $array2[$j]\n"; last; } } } __END__ abc_RCF_BM_allocation_0_kl contains BM_allocation_0 aplc_RCF_BM_allocation_0_in_nml contains RCF_BM_allocation_0_in fbe_RCF_BM_allocation_0_in_tvg contains RCF_BM_allocation_0_in ap_hu_BM_allocation_0_in_nml contains BM_allocation_0
In reply to Re: check 2 string arrays
by toolic
in thread check 2 string arrays
by sharan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |