sub while_with_shift_push { my $ref; my @cp = @arr; push( @$ref, shift( @cp ) ) while @cp; return $ref; }