while (my @lines = grep defined, (scalar , scalar )) { print RESULT @lines; }