# Wrong, and the cause of the OP's problem. See my reply to the OP. binmode(STDIN, ':encoding(UTF-8)'); #### # Necessary to encode the returned HTML. binmode(STDOUT, ':encoding(UTF-8)');