foreach my $i (0 .. ($#array/2) - 1) { ... }This produces an off-by-one error. Either
>perl -wMstrict -le "my @ra = qw(a A b B c C d D e E); for my $i (0 .. ($#ra/2) - 1) { print qq{$ra[ $i * 2 ] : $ra[ $i * 2 + 1 ]}; } " a : A b : B c : C d : D >perl -wMstrict -le "my @ra = qw(a A b B c C d D e E); for my $i (0 .. ($#ra/2)) { print qq{$ra[ $i * 2 ] : $ra[ $i * 2 + 1 ]}; } " a : A b : B c : C d : D e : E
In reply to Re^2: Accessing array elements
by AnomalousMonk
in thread Accessing array elements
by Ravendark
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |