Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Perl Loops

by vinoth.ree (Parson)
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
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 rifling through the Monastery: (6)
As of 2014-11-27 14:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (186 votes), past polls