Stuart, can we please see the whole script?
Stuart, I reworked the for loops to do what I believe you intended and made a few other general cleanups. See if this gets you going:
#!/usr/bin/perl # primeNumbers.pl use warnings; use strict;
print "Enter a number that is bigger than 2:\t"; chomp( my $input = <STDIN> ); print "This is your number: $input \n"; my @list = (2 .. $input);
#this foreach loop goes through the @list array, putting the odd
#numbers into a new array, @primelist
my @primelist;
foreach (@list) { unshift @primelist, $_ if ($_ % 2); }#for loops that will loop through @list and @primelist, getting the
#modulus of @primelist. I anticipate that this will isolate prime
#numbers.
my @newPrimeList;
PRIMES: for my $possible_prime (@primelist) {
for my $test (3..($possible_prime - 1)) {
next PRIMES unless $possible_prime % $test;
}
push @newPrimeList, $possible_prime;
}
print "this is primelist: @primelist\n";
print "this is newPrimeList: @newPrimeList\n";__END__
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
