Re: beginner counting question
- From: Purl Gurl <purlgurl@xxxxxxxxxxxx>
- Date: Fri, 30 Mar 2007 11:49:19 -0700
guba wrote:
@list = ('40', '30', '30', '20');
The entries in this list are control numbers
that define the number of steps something
must be done. The question is how a
counting variable can be defined that counts
continuously inside two loops i.e. I want
something like
do 40 steps something and count from 1..40
do 30 steps something and count from 41..70
do 30 steps something and count from 71..100
do 20 steps something and count from 101..120
#!perl
@Steps = (2, 4, 4, 2);
for (@Steps)
{
for (1 .. $_)
{
print "$_ ";
$count++;
}
print "\nCOUNT: $count\n";
}
PRINTED RESULTS:
1 2
COUNT: 2
1 2 3 4
COUNT: 6
1 2 3 4
COUNT: 10
1 2
COUNT: 12
Purl Gurl
.
- Follow-Ups:
- Re: beginner counting question
- From: guba@xxxxxxxxxx
- Re: beginner counting question
- References:
- beginner counting question
- From: guba@xxxxxxxxxx
- beginner counting question
- Prev by Date: Re: Perl versus other scripting language
- Next by Date: Regexp non-alphanumerics to spaces
- Previous by thread: beginner counting question
- Next by thread: Re: beginner counting question
- Index(es):