unpack 'i/A*',$_;
however it does not seem to work.
One thing I've noticed is that if I try to unpack the message from the server whithout the while loop, I only get the first line back + the gibberish. If I do a while loop as in the code then I get all the message + gibberish.
Could the problem lie in the fact that the message has a carriage return? I'm drawing a blank