while (<>) { # Added a conditional per merlyn's advice /(\S*)\s+(\S*)/ or next; # /(\S*)\s+(\S*)/; push @a, $1 if length $1; push @b, $2 if length $2; } print "First column output:\n\n@a\n\n", "Second column output:\n\n@b\n\n"