我有一个批处理系统,需要一遍又一遍地运行相同的 shell 命令。
while (x)
{
if (y)
{
$diff = `diff $f1 $f2`;
...
}
else
{
...
...
这有点慢,所以我想知道是否有某种方法可以使 shell 或程序持久化(或其他东西),这样就不会每次都有很大的开销。
请注意,我不能真正考虑编写自己的 diff
函数,因为实际输出需要看起来像是来自该程序。
提前致谢!
最佳答案
I'm wondering if there's some way to make the shell or program persistent (or something) such that it doesn't have the big overhead every time.
不是真的。 diff
本质上是一种一次性工具;它没有任何持久模式。
不过,您可能想看看 Text::Diff模块。它可以生成与 diff
实用程序相同格式的输出。
关于Perl - 需要一遍又一遍地调用系统 ('diff' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55776492/