binmode(STDOUT, ":encoding(euc-cn)") binmode(STDOUT, ":encoding(gb2312)") or convert each individual string $text = encode('euc-cn', $text)