perl读取文件内容

2016-10-18 07:53:48来源:CSDN作者:g13731463274人点击

[root@mysql1 perl]# cat test.pl 


#!/usr/bin/env perl


while (defined($line=<>)) {
  chomp($line);
  print "it was $line that i saw!/n";
}












[root@mysql1 perl]# ./test.pl a.txt b.txt


it was a that i saw!
it was b that i saw!
it was c that i saw!
it was d that i saw!
it was e that i saw!
it was i was the end! that i saw!
it was a that i saw!
it was b that i saw!
it was c that i saw!
it was d that i saw!
it was e that i saw!
it was i was the end! that i saw!














[root@mysql1 perl]# cat a.txt 
a
b
c
d
e
i was the end!






[root@mysql1 perl]# cat b.txt 
a
b
c
d
e
i was the end!































最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台