Alin Tudor
Alin Tudor

Reputation: 39

Modified addition to a variable in Perl

Hi I have an for loop in which I declared another if block and what I want to do is to add to a external $a variable(external of for loop) in a first scroll of if block +1, in a second scroll +2 and so on with a while condition to be less than a value. Is there a way to ad a different value at every if block scroll?

Upvotes: 0

Views: 77

Answers (1)

ikegami
ikegami

Reputation: 385857

So you have something like this?

while (condition) {
   ...
}

Then all you need is the following:

my $i = 0;
while (condition) {
   ++$i;
   ...
}

Upvotes: 2

Related Questions