Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Store last value of for loopby sandy1028 (Sexton) |
on Jan 15, 2009 at 05:15 UTC ( [id://736459]=perlquestion: print w/replies, xml ) | Need Help?? |
sandy1028 has asked for the wisdom of the Perl Monks concerning the following question:
I have an articles where each article contains 2 or more articles nested.
I have used threading concept to thread it.
The values of the article is not in sequential.
Suppose first article has 2 articles within it and second article has 6 articles.
The value of the article is
Count of articles_id displays
2,6,etc.
$i=0;
for my $id(@article_id){
print $i;
$i++;
}
output will be 1,2,1,2,3,4,5,6
The for loop initializes the value as 0 for each article.
How to store the value of last value of the varible when exits from each iteration.
So that the value is 1,2,3,4,5,6,7,8.
Back to
Seekers of Perl Wisdom
|
|