这一个让我。Perl循环没有打印出字符
这工作:
print "Processing Feed\n";
while (my @p = $mainex->fetchrow_array) {
my $iis = "$pcount";
print "$iis\n";
# ... Do Other Stuff Here
$pcount++;
}
其中给出:
Processing Feed
1
2
3
4
5
6
7
8
9
10
...
这不起作用(除去从第4行的\ N):
print "Processing Feed\n";
while (my @p = $mainex->fetchrow_array) {
my $iis = "$pcount";
print "$iis";
# ... Do Other Stuff Here
$pcount++;
}
它只是给出了:
Processing Feed
我试图建立一个计数器,将其输出高达使用类似的记录的计数:
while(Something){
print "\b\b\b\b\b\b\b\b\b\b\b";
print "$count";
$count++;
# Do stuff here
}
任何想法,为什么当出现在第二个例子中没有任何\ n被打印到屏幕?之前我已经做了很多次,并且不知道为什么它不起作用。
您不需要强制'$ count'作为[print] $ count“;'作为['print'](http://p3rl.org/print”perldoc -f print“)的字符串。迫使它充当一个字符串。所以只需写'print $ count;'。至于'print'$ iis \ n“;'vs'print $ iis,”\ n“;在这种情况下,真的没关系。 – 2013-03-22 01:33:56