Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Perl Loops

by vinoth.ree (Monsignor)
on Jun 29, 2013 at 20:34 UTC ( [id://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

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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1041511]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2024-03-28 13:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found