Perl:遍历文件并替换 [英] Perl: Loop through a file and substitute
本文介绍了Perl:遍历文件并替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是想读一个日志文件,进行搜索和替换,然后将更改写出到同一日志文件.
I simply wanna read in a logfile, do a search and replace, and then write out the changes to that same logfile.
在Perl中执行此操作的最佳实践方法是什么?
What's the best practice way of doing this in Perl?
推荐答案
我通常为此编写一个衬里:
I normally code up a one liner for this:
perl -i -pe 's/some/thing/' log.file
请参见此处
这篇关于Perl:遍历文件并替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文