my @arr = qw/1 2 3 4 5 6 7 8/; push @arr, undef; push @arr, 9; my ($j,$i)=(0,0); my ($x,$y) = ([grep { ++$i % 2} @arr] , [grep {$j++ % 2} @arr]); $i=0; for(@{$x}){ say $_ ." => " . $y->[$i++] if($_); }