STDIN

来源:互联网 发布:cn域名备案和com 编辑:程序博客网 时间:2024/05/16 17:50

#! /usr/bin/perl
$number1=<STDIN>;
$number2=<STDIN>;
$i=0;
while($i<$number2){
print "$number1/n";
$i++;
}

 

结果

C:/Perl/test>perl 2_1.pl
hello
3
hello


hello


hello

不是

C:/Perl/test>perl 2_1.pl
hello
3
hello
hello
hello

 

因为:<STDIN>中的字符串通常由一个换行符作为结尾

原创粉丝点击