Apart from the other comments, using
grep with user-supplied
data as the pattern (as your $uname variable may be) is evil
and should be avoided, because it opens the possibility to
all sorts of mischief. What if $uname contains regular
expression metacharacters? What if it contains one of the
magic forms that allow you to execute arbitrary Perl code?
I would also suggest using hashes for storing the user names.
Makes your code a lot cleaner and makes it much easier to
test whether a user is already there.
For some related discussion, see the FAQ
How can I tell whether a list or array contains a certain element?
--ZZamboni