Use modulo arithmetic to decide which elements are even:
Change the details to match your specific problem, but using % is usually what you want.for my $i (0..$#array) { print $array[$i]; print "\n" if $i % 2 == 0; }
In reply to Re: inserting a new line after some elemnts in an array
by duff
in thread inserting a new line after some elemnts in an array
by s_gaurav1091
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |