sharan has asked for the wisdom of the Perl Monks concerning the following question:
I want my output as:array1 array2 read book eat apple book novel apple banana play football tennis football novel mazagine
i tried implementing it with simple for loops as:Hi all, I am trying to implement a co-relation problem in perl. I have two ar +rays i.e. array1 and array2 which contain following values. <c> array1 array2 array3 array4 read book novel magazine eat apple banana play football tennis
But its not showing the proper output. It shows some random output in array3 and array4. Please guide me. Thanking you,for($i=0;$i<$arraylength;$i++) { for($j=0;$j<$arraylength;$j++) { if($array2[$i]== $array1[$j]) { $array3[$i] = $array2[$j]; } } } for($i=0;$i<$arraylength;$i++) { for($j=1;$j<$arraylength;$j++) { if($array2[$i]== $array2[$j]) { $array3[$i] = $array1[$j]; } } } for($i=0;$i<$arraylength;$i++) { for($j=0;$j<$arraylength;$j++) { if($array2[$i]== $array1[$j]) { $array4[$i] = $array3[$j]; } } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: compare 2 arrays of strings and form a table
by Roy Johnson (Monsignor) on Mar 10, 2009 at 18:09 UTC | |
Re: compare 2 arrays of strings and form a table
by eff_i_g (Curate) on Mar 10, 2009 at 17:24 UTC | |
Re: compare 2 arrays of strings and form a table
by ikegami (Patriarch) on Mar 10, 2009 at 18:01 UTC | |
by ikegami (Patriarch) on Mar 10, 2009 at 18:37 UTC |