in reply to unicode in function

Redhat 8 by default sets some environment variables to set the default endcoding to UTF8. You can either change your script to call binmode() on the socket handle, or make sure that none of LANG, LANGUAGE, LC_ALL and LC_CTYPE environemtn variable mention UTF8.