且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Perl 脚本用另一行更新文件的一行

更新时间:2022-06-21 22:57:33

我这样做的方法是打开一个输入文件句柄和一个输出文件句柄,然后逐行通过文件检查列第一,如果没关系,只需将其按原样放入我的输出中即可.

The way I would do this is to open an input file handle and an output file handle, and go line by line through the file checking column one and, if its fine, just plop it into my output just as it is.

如果确实需要更改,我会创建一个包含必要更改的新行并将其放入我的输出文件中.

If it does need to change, I would make a new line with the necessary changes and put it into my output file as well.

这是一种简单的方法,虽然不是***的/优雅的/任何东西,但可以快速为您提供所需的东西.

This is a simple approach, that while not the greatest/elegant/whatever, would give you what you need quickly.