in reply to Resetting Internal Loop Pointers

If you want a finer level of control than a redo, you can pull the keys function out of the loop and then iterate over an array with a counter. Then you will have the ability to manipulate the counter however you wish. Here's a simplistic example:
use strict; my %hash = (test1 => 1, test2 => 2, test3 => 3, test4 => 4); my @array = sort(keys(%hash)); my $counter = 0; my $resetter = undef; my $resets = 0; while($counter <= $#array){ if(defined($resetter)){ $counter = 0; $resets++; } $resetter = undef; print $hash{@array[$counter]}; $counter++; $resetter = 1 if $counter > 2 and $resets < 2; }
If all you need is the ability to restart the loop, the for/redo suggestion above requires a smaller code change.