#!/usr/bin/perl -wT use strict; my @a = qw(1 2 3 4 5 6); my @b = qw(a b c d e f g h i); my $max = $#a > $#b ? $#a : $#b; # find the max index of the biggest array for my $i (0..$max) { # loop through using the same index variable print "$a[$i]\n" if defined $a[$i]; print "$b[$i]\n" if defined $b[$i]; } =OUTPUT 1 a 2 b 3 c 4 d 5 e 6 f g h i