in reply to Variable messes up loops.

Let's have a look at that subroutine, shall we? I've asked emacs' cperl mode to indent it for us.
sub login { $/ = "\015\012"; print $client "username:"; $login=<$client>; chomp $login; if ($login eq "") { print $client "Must enter a username!\n\r"; &login; } $/ = "\012"; open (FILE1, "users.txt") || print "Error occured while opening +file"; while (<FILE1>) { ($first,$second ) = split /:/; print $first; if ($login eq $first) { print $client "Sorry this username has been taken, try again +!\n\r"; &login; } $/ = "\015\012"; } close (FILE1); ...

What this highlights quite clearly, is that you're resetting $/ whilst you're still reading the file. Try moving it to outside the loop.

In addition, if it doesn't like the value it's found, then it's going to call &login again, while the file is still open. Which means that the file will be reopened, and $/ set inside a recursive call, then closed and reset when that recursive call ends. Not good thing.

In fact, the logon subroutine doesn't finish until 7 lines from the end of the script, containing the password subroutine on the way. Not good at all