in reply to Substring problem

You're reading from your filehandle twice each time through the loop. Don't do that.

while (<FILEHANDLE>) { my $ServerName = <FILEHANDLE>;

The cake is a lie.
The cake is a lie.
The cake is a lie.