Hi again Haukex. What i need to do is to make sure that my @array1 sequence is the same with @array2.

For example if my input is this:

my @array1 = ('ux_prim_clk', 'ux_side_clk', 'ux_xtal_frm_refclk');

my @array2 = ('ccu_ux_xtal_frm_refclk_ack', 'ibbs_ux_prim_clkack','sbr_ux_side_clkack');

And, after doing the comparison, my output is:

@array1 = ('ux_xtal_frm_refclk', 'ux_prim_clk', 'ux_side_clk')

@array2 = ('ccu_ux_xtal_frm_refclk_ack', 'ibbs_ux_prim_clkack','sbr_ux_side_clkack')

I want to use @array2 as reference and make sure that @array1 is following the same sequence as @array2. Note that i cannot simply use name to compare because the name of element inside @array1 & @array2 can be changed.

Let say from @array1, the first row's element is ('ux_prim_clk') and for the @array2, the first row's element is ('ccu_ux_xtal_frm_refclk_ack'). Now, i want to compare these two but i want to compare it word by word (Eg: ux & ccu, prim & ux, clk & xtal).

But the constraint now is that my @array2 first row's element has different size with @array1. So that's why i want to splice array2 first row's element and compare it with the first row's element of @array1. My @array1 is maintain throughout the comparison.

For example (using first row's element for both arrays):

@array1 = (ux, prim, clk) @array2 = (ccu, ux, xtal, frm, refclk, ack)

1. compare: ux & ccu, prim & ux, clk & xtal.

2. compare: ux & ux, prim & xtal, clk & frm.

3. compare: ux & xtal, prim & frm, clk & refclk.

4. compare: ux & frm, prim & refclk, clk & ack.

Each time it compares (1 - 4), i want to store the number of match inside let say $match variable, and overwrite it if it has highest number of match. For example:

$highest_match = 0; if ($match > $highest_match){ $highest_match = $match; } $highest_percentage = ($highest_match/no. of element in array1's row)* +100;

I will then plan to do condition if (highest_percentage > 50%), i will store the entire row of @array2 inside another array.

So i will end up with the output that i want inside this new array.

I hope this clears your confusion. I'm sorry i really bad at explaining. I only learn c language before so this language is very new to me. I really appreciate your effort.


In reply to Re^2: remove element from 2D array after comparing it with other 2D array by Newbie95
in thread remove element from 2D array after comparing it with other 2D array by Newbie95

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.