试验用的./test.txt 内容为
Helo, This is a test file.
This file contain a story about fred flintstone and his friend.
One day fred went to shoping, he met Sam who is his friend.
Sam was also for shopping. So they got together.
lalalal fred or wilma.
When they on their way home, they met frederick and Alfred.
Frederick and Alfred want to look after their granpa Mr. Slate.
this line just test Fred(后面一个tab)
and this line FRED
add this line Bamm-Bamm(后面两个空格一个tab)
wilma and fred
aa
abcdefhijk
foot
goooood(后面四个空格)
perl脚本为
#! /usr/bin/perl
if ( ! open TEST, "./test.txt") {
die $!;
}
while () {
chomp;
if (/.*(\s$)/) {
print "$&|end\n";
}
}
运行结果为:
this line just test Fred |end
add this line Bamm-Bamm |end
foot |end
goooood |end
Helo, This is a test file.
This file contain a story about fred flintstone and his friend.
One day fred went to shoping, he met Sam who is his friend.
Sam was also for shopping. So they got together.
lalalal fred or wilma.
When they on their way home, they met frederick and Alfred.
Frederick and Alfred want to look after their granpa Mr. Slate.
this line just test Fred(后面一个tab)
and this line FRED
add this line Bamm-Bamm(后面两个空格一个tab)
wilma and fred
aa
abcdefhijk
foot
goooood(后面四个空格)
perl脚本为
#! /usr/bin/perl
if ( ! open TEST, "./test.txt") {
die $!;
}
while () {
chomp;
if (/.*(\s$)/) {
print "$&|end\n";
}
}
运行结果为:
this line just test Fred |end
add this line Bamm-Bamm |end
foot |end
goooood |end
编辑回复