程序:
#!/usr/bin/perl -w use strict; my $num=ord 'E'; print "The ASCII is : $num\n"; my $word=chr(69); print "The word is : $word\n";
结果:
The ASCII is : 69
The word is : E
本文通过Perl编程展示了如何将字符转换为其对应的ASCII数值,并反向操作将ASCII数值转回字符。这种基本操作对于理解计算机中字符的编码方式非常重要。
程序:
#!/usr/bin/perl -w use strict; my $num=ord 'E'; print "The ASCII is : $num\n"; my $word=chr(69); print "The word is : $word\n";
结果:
The ASCII is : 69
The word is : E
2190

被折叠的 条评论
为什么被折叠?