in reply to Splitting a string... Duh?

You have two problems here. The first is the unescaped special character / as your split pattern, and the second is the use of a scalar variable in list context (already commented upon in other answers to your question).

You need to remove the special meaning from / in order for split to be able to use it. Single quotes, which suppress interpolation, is the easiest on the eyes. You could also use "\/", /\//, m|/|, etc., consult perldoc perlre or your favorite perl reference for details.

Next, by default split returns a list of strings. You either need to catch these with an array and then use the first item in that array ($cnID[0]), or assign your scalar $cnID to the first member of the list explicitly.

This is similar to podmaster's answer, but keeps the list on the right hand side of the assignment:  my $cnID = (split '/', $serverID,2)[0]; The last argument to split tells split to break $serverID into no more than 2 pieces - no need to bother with any more, given that you only want the first piece anyway.

Originally posted as a Categorized Answer.