in reply to Re: code that fails to act as expected...
in thread code that fails to act as expected...

Thank you, citromatik. When I implement some of your examples, I notice, now, another baffling action:
my %couples = ( george => 'gracie', abbot => 'costello', johnson => 'boswell',); while (my($c, $d) = each %couples) { print "$c $d\n"; } print "\n"; foreach my $c (each %couples) { print "$c\n"; } print "\n"; while ( my($c, $d) = each %couples) { print "$d $c\n"; }
The first foreach example code you offered, when run prior to the first while loop you suggested, causes the while loop to drop one of the key, value pairs.The same while loop, run before the foreach loop, outputs all three key, value pairs.

What causes that behavior? Does the scope of the foreach loop manage to extend, in some way, to the following while loop?

Thanks, again, for helping with this.