> 
> Stuart, can we please see the whole script?
> 

#!/usr/bin/perl
# primeNumbers.pl
use warnings;
use strict;
my $input;
my @list;
my @primelist;
my @newPrimeList;
my $i;
my $j;
print "I want you to enter a list of numbers bigger
than 2.\n";
print "To mark the end of your list, enter 0.\n";
print "Enter a number that is bigger than 2:\t";
$input = <STDIN>;
chomp($input);
print "This is your number: $input \n";
@list = (2 .. $input);

print "this is this the fourth element, but has an
index of 3: $list[3]\n";
#this foreach loop goes through the @list array,
putting the odd
#numbers into a new array, @primelist

foreach (@list)
{ 
 if ($_ % 2 != 0)
 {
  unshift(@primelist, $_);
        print "this is the inner loop of primelist:
@primelist\n";  
 }
}
print "this is the outer loop of primelist:
@primelist\n";  

#for loops that will loop through @list and
@primelist, getting the
#modulus of @primelist.  I anticipate that this will
isolate prime
#numbers.
 for ($i = 0; $i <= $input; $i++)
 {
  for ($j = 0; $j <= $input; $j++)
        {
   if ($primelist[$i] % $list[$j])
         {
          unshift(@newPrimeList, $primelist[$i]);
                print "I just added $primelist[$i] to
newPrimeList.\n";
         } 
        }
 }      
 print "this is primelist:  @primelist\n";
 print "this is newPrimeList:  @newPrimeList\n";
  

> James
> 


__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to