Hi gilthoniel,
Welcome to the Monastery.
As already hippo and marinersk given you the algorithm to achieve your result, they missed to tell you How to check a number is divisible by another number.
To check if a number is divisible by another number use the modulus operator, %:
if ($num % $divisor) { # does not divide cleanly } else { # does. }I hope you have read the perlintro, So here i am giving you the code skeleton
#array declaration my @array1 = (....); my @array2 = (....); my ($num,$divisor); foreach $num (array contains dividend) # this loop is for iterator on +e by one { foreach $divisor (array contains divisor) # this loop checks f +irst array elements array divisible by the second array element { if ($num % $divisor) { # does not divide cleanly print "$num is not divisible by $divisor\n"; } else { # does. print "$num is divisible by $divisor\n"; } } }
In reply to Re: Comparing two arrays
by vinoth.ree
in thread Comparing two arrays
by gilthoniel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |