in reply to Real confusion with loops and counters

If I were you I would reword my question a bit. You aren't comparing two lists of sorted numbers, really, but rather two lists of "things". You want to check everything in list1 to see if it is in list2. If it is, go for a party! If not, go to a different party! (Sorry, early Friday morning sense of humour there). So, you could write it like this:

my @list1 = (1,3,4,5,6,7); my @list2 = (1..100); foreach my $list1_item (@list1) { my $flag = 0; foreach my $list2_item (@list2) { if ($list1_item == $list2_item) { $flag = 1; last(); } } if ($flag == 0) { print $img1; } else { print $img2; } }

So basically we just loop over list1, see if it's elements are in list2. If they are, set the flag variable, stop looping and print it. If they aren't, print the alternate image. There are definitely more concise and efficient ways to code that, but this is clear and will work if you move from numbers to strings, objects, etc.

-Tats