本文介绍了如何在Perl中区分两个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个需要具有相同值的文本文件。

I have two text files which need to have the same values.

$ diff A.txt B.txt
4a5
> I have this extra line.
$

在Perl中打开文件

open (ONE, "<A.txt");
open (TWO, "<B.txt");

如何在Perl中进行这种比较? Perl是否具有内置的差异,还是我需要使用unix diff 实用程序?我不想为此实现自己的差异算法。

How can I do such a diff from within Perl? Does Perl have a inbuilt diff or do I need to use the unix diff utility? I don't want to implement my own diff algorithm for this.

我确实需要有关文件不同之处的信息,但不需要使用UNIX diff 实用工具。只是一个例子。

I do need the information as to where my files differ, but I do not need to use the unix diff utility necessarily. That was just an example.

推荐答案

您可以尝试使用

或者,UNIX实用程序是一种选择。

Alternatively, the UNIX utility could be an option.

这篇关于如何在Perl中区分两个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 17:44