in reply to IO::Socket and passed variables to functions

In what way is the contents of $grp "weird" ?

AFAICS, you collect what you receive from the client so: @push(@groups, $buf) and later $grp = shift(@groups)... so, unless what you receive is not what you expect it's hard to see what could be wrong. I note you did a chomp($buf) -- in a network environment, where CRLF is a common line ending, $buf =~ s/\s+$// will do a complete job (while chomp may not).

I am also required to mention use strict and use warnings.