in reply to inserting a new line after some elemnts in an array
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; }
|
|---|