Hi, I have to compare 2 string arrays. my 2 arrays are as follows:
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 have to check whether array1 contain array2 or not. therefor my ouput should be like:
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
I tried with:
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]"; }}}
But it didnt work. Please guide me to compare the strict strings.
Thanking you,

In reply to check 2 string arrays by sharan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.