我不明白“W”到底是做什么的。
my $x = "this is my string";
print unpack("W",substr($x,0,1));
打印:116
my $x = "this is my string";
print unpack("W",$x);
静态照片:116
从perldoc:W An unsigned char value (can be greater than 255).
您的两个示例都返回相同的内容,因为您的 unpack 参数"W"
仅使用一个字符。试试"W*"
吧。