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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |