Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Perl Loops

by vinoth.ree (Prior)
on Jun 29, 2013 at 20:34 UTC ( #1041511=note: print w/ replies, xml ) Need Help??


in reply to Perl Loops

Hi stam1982

For:
#!/usr/bin/perl use strict; use warnings; for (my $n = 2; $n < 21; $n += 2){ print "$n\n"; }
while:
#!/usr/bin/perl use strict; use warnings; my @evens; my $n = 0; my $number_to_give_up_at = 21; # $#evens will contain value of index of last element in @evens array while ($n++ < $number_to_give_up_at and $#evens < 9){ push @evens, $n if $n % 2 == 0; } print join("\n", @evens);

All is well


Comment on Re: Perl Loops
Select or Download Code
Replies are listed 'Best First'.
Re^2: Perl Loops
by stamp1982 (Novice) on Jun 29, 2013 at 21:08 UTC
    Farang: How will you do that using the until/do-until loops?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1041511]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2015-07-29 02:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls