-2
我有一個很大的文件(有超過20,000行),其中一些行正在用「+」盯着。它的形式如下:使用perl編輯文件
This is a file with many lines
Some lines start with plus
+ line one
+ line two
Some lines do
not start with plus
+ line three
+ line four
我想加入所有以+開頭的行和前一行。所以我的輸出應該是這樣的:
This is a file with many lines
Some lines start with plus line one line two
Some lines do
not start with plus line three line four
我該怎麼用perl做這個?
很好的解決方案。也許可以考慮:'也許BEGIN {$ /。=「+」}' – Miller 2014-09-25 20:09:10
@Miller,但這種方式似乎更清楚(至少對我來說:)) – 2014-09-25 20:11:05