sharan has asked for the wisdom of the Perl Monks concerning the following question:
I have to check whether array1 contain array2 or not. therefor my ouput should be like:array1 array2 abc_RCF_BM_allocation_0_kl RCF_BM_allocation_0_in aplc_RCF_BM_allocation_0_in_nml BM_allocation_0 fbe_RCF_BM_allocation_0_in_tvg RCF_BM_allocation_0 ap_hu_BM_allocation_0_in_nml
I tried with:abc_RCF_BM_allocation_0_kl contains RCF_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
But it didnt work. Please guide me to compare the strict strings.for($i=0;$i<$array1length;$i++){ for($j=0;$j<$array2length;$j++){ if($array1[$i] =~ /\b$array2[$j]\b/) {print "$array1[$i] contains $array2[$j]"; }}}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: check 2 string arrays
by toolic (Bishop) on Mar 31, 2009 at 13:01 UTC | |
by sharan (Acolyte) on Mar 31, 2009 at 13:15 UTC | |
by jethro (Monsignor) on Mar 31, 2009 at 13:44 UTC | |
|
Re: check 2 string arrays
by eff_i_g (Curate) on Mar 31, 2009 at 14:11 UTC | |
|
Re: check 2 string arrays
by jethro (Monsignor) on Mar 31, 2009 at 13:08 UTC | |
|
Re: check 2 string arrays
by cdarke (Prior) on Mar 31, 2009 at 13:13 UTC | |
by sharan (Acolyte) on Mar 31, 2009 at 13:21 UTC | |
|
Re: check 2 string arrays
by Ish (Acolyte) on Mar 31, 2009 at 16:17 UTC |