in reply to Re: check 2 string arrays
in thread check 2 string arrays

Hi Toolic,
I tried with if ($array1[$i] =~ /$array2[$j]/) But i still have some error.e.g. it shows 2 outputs for some strings
abc_RCF_BM_allocation_0_kl contains BM_allocation_0 abc_RCF_BM_allocation_0_kl contains RCF_BM_allocation_0 aplc_RCF_BM_allocation_0_in_nml contains RCF_BM_allocation_0_in aplc_RCF_BM_allocation_0_in_nml contains BM_allocation_0
Still i didnt get what could be the problem.

Replies are listed 'Best First'.
Re^3: check 2 string arrays
by jethro (Monsignor) on Mar 31, 2009 at 13:44 UTC

    Note the 'last;' in toolics version of the search loop. That makes sure that the loop stops as soon as the first solution is found.

    After that the only thing left to do is to order array2 so that the first found solution is always the one you want