@users = grep { $_ } @users; #eleminate undef elements #### next unless $user; #after the chomp (which could be done on the whole array outside the loop print $user . '.mydomain.com' if $user;