首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

初学perl,字符串轮换标量变量

2012-08-13 
初学perl,字符串替换标量变量Perl code1 #!/usr/bin/perl2 $line hello3 printf ${line}world\n4

初学perl,字符串替换标量变量

Perl code
  1 #!/usr/bin/perl  2 $line = "hello";  3 printf "${line}world\n";  4 $width = <STDIN>;  5 printf "%${width}s\n",$line;


最后一行为什么不会格式化输出呢?书上说可以呀!!!
[ready@localhost perl_test]$ ./test.pl
helloworld
12
%12
s
输出来的是这个

[解决办法]
回车读进去了,去掉就OK
Perl code
$line = "hello";printf "${line}world\n";chomp($width = <STDIN>);printf "%${width}s\n",$line; 

热点排行