I'm really new to programming and I have two number arrays (ex. array1 = 13, 29, 545 array2 = 5,7,9 etc). I want to see which numbers in array 1 are not divisible by any of the numbers in array 2. Is there an easy way to do this? Thanks Update: Marinersk: *very* new. I've read the basic perl usage info. I know what arrays and hashes are and how to declare variables and print things and the very basic stuff, but I find a lot of the perl manuals go straight from very basic "this is how to declare a variable" to really complex code I don't understand and are missing a lot of the middle ground. Thanks so much! Here is my script, and it works. Thanks for the help! #!/usr/bin/perl use strict; use warnings; my @array1 = (3, 5, 7, 9); my @array2 = (13, 29, 35, 55, 71, 545); foreach(@array1) { my $num1 = $_; foreach(@array2) { my $num2 = $_; if($num2 % $num1 == 0) { print "$num2 is divisible by $num1 \n"; } else { print "$num2 is not divisible by $num1 \n"; } } }

In reply to Comparing two arrays by gilthoniel

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.