【发布时间】:2012-12-08 19:11:51
【问题描述】:
我是 perl 新手,我正在学习使用 O'reillys Learning Perl 书。像 ♠ 这样的 Unicode 字符(如书中所写)可以使用 print "\x{2668}" 打印。我使用foreach loop 打印一系列Unicode 字符。
示例:从 2660 到 2670;
我已经写了以下代码,
foreach $num (2660..2670)
{
print "Character for $num is:","\x{$num} \n";
}
它给出了以下输出,
Illegal hexadecimal digit '$' ignored at ./Printing_messages.pl line 10.
Character for 2660 is:
Character for 2661 is:
Character for 2662 is:
Character for 2663 is:
Character for 2664 is:
Character for 2665 is:
Character for 2666 is:
Character for 2667 is:
Character for 2668 is:
Character for 2669 is:
Character for 2670 is:
之后我做了一些其他的调整,但没有任何效果。我的程序有什么问题?我不明白。有没有办法让它工作?
【问题讨论】:
标签: perl string-interpolation widechar