I have a minimal working example of two nested while loops on the same array @g:
#!/usr/bin/env perl
use 5.042;
no source::encoding;
use warnings FATAL => 'all';
use feature 'say';
use autodie ':default';
my @g = qw(Matthew Mark Luke John);
while (my ($i, $gos) = each @g) {
say "$i => $gos";
while (my ($j, $g2) = each @g) {
say "\t$j=>$g2";
}
}
This particular loop gets stuck on the first iteration $i, and never moves on to the 2nd.
The infinity is easily fixed by foreach my $gos (@gos) { instead of the first while.
Is this a bug or an intended feature?
Shouldn't foreach my $gos (@g) in the first line be the exact equivalent of while (my ($i, $gos) = each @g) {?