in reply to Re^3: Perl program - I hope I can more understand my code
in thread Perl program - I hope I can more understand my code
Push is not necessary to achieve the result, but here is how you could use it:
sub listprimes { my ($n) = @_; my @primes_leq_n; for my $p (@primes){ # for and foreach are synonymous last if $p > $n; push @primes_leq_n, $p; } return join " ", @primes_leq_n; }
The best defense against logic is ignorance.
|
|---|