Test file when found that the output of Chinese is garbled, so learned a bit of Perl encode principle. Now do a summary:
The basic knowledge of Perl: In Perl, there are only two forms of strings. One is octets, a 8-bit sequence, which is the byte array we usually say. Another type of UTF8 encoded string, Perl tube it is called string. That is to say: Perl only knows two encodings: Ascii (octets) and UTF8 (string).
So when the output is garbled, the UTF8 encoding should be converted into a form acceptable to the user. For example, Chinese with gb2312.
My $s = ":< Chinese keywords >= British Royal Society;; The Journal of Philosophical Transactions Physical sciences;; Scientific communication. ";
$a = $s =~/>= (. +) $/;
Print encode (' gb2312 ', $ $). " \ n "; #输出英国皇家学会;; The Journal of Philosophical Transactions Physical sciences;; Scientific communication.
Perl Output Chinese is garbled