Hi all, I am trying to implement a co-relation problem in perl. I have two arrays i.e. array1 and array2 which contain following values.
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.#Step no.1 for($i=0;$i<$arraylength;$i++) { for($j=0;$j<$arraylength;$j++) { if($array2[$i]eq $array1[$j]) { $array3[$i] = $array2[$j]; } } } #Step no.2 for($i=0;$i<$arraylength;$i++) { for($j=$i+1;$j<$arraylength;$j++) { if($array2[$i]eq $array2[$j]) { $array3[$i] = $array1[$j]; } } } #Step no.3 for($i=0;$i<$arraylength;$i++) { for($j=0;$j<$arraylength;$j++) { if($array2[$i]eq $array1[$j]) { $array4[$i] = $array3[$j]; } } }
I guess there is some problem in the step no.2. It shows error stating that 'array3' cannot be null.
How can we initialize array to null values??
my @array3=(); #is it correct??
When the second step executes.. it compares the two same value but the value stored in array3 from array1 is not a string infact something like..HASH(0x82e3594), HASH(0x82e35a0). What could be the problem. Please guide me. Thanking you,In reply to how to initialize array to null values by sharan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |