in reply to undef line in an array

You have an empty element you want to ignore? How about one of:
@users = grep { $_ } @users; #eleminate undef elements
or in your loop either of:
next unless $user; #after the chomp (which could be done on the whole +array outside the loop print $user . '.mydomain.com' if $user;