![]() |
| ||
| if the index is an even number Hi all , I have loop and I would like to calculate an expression only when the index is even for($j=0; $j<=100; $j++){ if ( ){ do the expression } } i.e how do I tell perl to do the if statement when $j is an even number? Thanks |
| ||
| Re: if the index is an even number for($j=0; $j<=100; $j++){
If you are doing some mathematical operation with the expression i think you want to re-check whether loop should start from 0. katharnakh. |
| ||
| Re: if the index is an even number If you want to process the even number indices of an array: for (my $i = 0; $i <= $#array; $i+=2) { |
| All times are GMT -4. The time now is 4:50 pm. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC