while(my($one,$two)=(shift(@aray),shift(@aray)) ) { ... #or even while(my($one,$two) = splice(@aray,0,2) ) { ... #### my @array = qw/ 1 2 3 4/; while(my($one,$two) = Each(\@array) ) { print "$one = $two \n"; } sub Each { my $r = shift; my $counter; unless(@$r) { warn "empty array"; return; } unless($r->[-2] eq $r) { push(@$r, $r); push(@$r,0); } $counter = $r->[-1]; my $one = $counter < scalar(@$r) - 3 ? $r->[$counter] : undef; $counter++; my $two; if( $counter < scalar(@$r) - 2 ) { $two = $r->[$counter]; } else { warn "finally gone through it"; return; } $r->[-1] = $counter; if(2 == @$r) { warn "gone trhough it, nothing left to see"; return; } return ($one, $two); }