怎样根据某个含有unicode码的变量转换成字符

怎样根据某个含有unicode码的变量转换成字符

怎样根据某个含有unicode码的变量转换成字符
怎样根据某个含有unicode码的变量转换成字符,然后输出到文件?
例如
$str="0030 0031 0032 0033";
@str=split(/ /,$str);
foreach $code (@str)
{
$letter="\x{$code}"; #行不通
$letter="\x{0030}"; #可行,但我希望括号里面是变量
print FH "$letter";
}
pack TEMPLATE,LIST-- pack TEMPLATE,LIST

Takes a LIST of values and converts it into a string using the rules given by the TEMPLATE. The resulting string is the concatenation of the converted values. Typically, each converted value looks like its machine-level representation. For example, on 32-bit machines a converted integer may be represented by a sequence of 4 bytes.
u A uuencoded string.
U A Unicode character number. Encodes to UTF-8 internally
(or UTF-EBCDIC in EBCDIC platforms).


The TEMPLATE is a sequence of characters that give the order and type of values, as follows:
使用pack仍是不太明白
$str="0x0030,0x0030,0x0031,0x005F,0x0031";
$str=pack "U5",$str; #行不通

@str=split(/,/,$str);
$str=pack "U5", @str; #仍行不通

$str=pack "U5",0x0030,0x0030,0x0031,0x005F,0x0031; #可行,但不是我想要的
大虾帮帮忙!
[quote]use encoding
[quote]use encoding "utf8"; # 避免在打印的时候出现 Wide character in print at - line x. 的提示消息
$str="0x0030,0x0030,0x0031,0x005F,0x0031,0x6c49";
$s.=pack "U",hex $_ for split /,/,$str;
print $s;[/quote]




   

谢谢cnhacktnt
谢谢cnhacktnt, 很好用。
俺第一次发帖请教就获得圆.
俺第一次发帖请教就获得圆满答案,谢谢各位大侠相助。