您的位置:首页 > 其它

Perl计数器

2015-06-01 20:20 302 查看
jrhapt01:/home/tomcat/sbin> cat test.out
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
You have new mail in /var/spool/mail/tomcat
jrhapt01:/home/tomcat/sbin> wc -l test.out
15 test.out

jrhapt01:/home/tomcat/sbin> cat test.pl
open( D, "<", "test.out" ) || die "$!\n";
while (<D>)
{
$num++;
print "\$num is $num\n";
}

jrhapt01:/home/tomcat/sbin> perl test.pl
$num is 1
$num is 2
$num is 3
$num is 4
$num is 5
$num is 6
$num is 7
$num is 8
$num is 9
$num is 10
$num is 11
$num is 12
$num is 13
$num is 14
$num is 15
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: