如何读取系统调用后的生成的日志文件差异?

如何读取系统调用后的生成的日志文件差异?

需求如下
执行某system call后会往日志文件里生成一些log
现在想把执行前后的日志文件差异部分打印出来,怎么做?


QUOTE:
原帖由 linhao 于 2007-12-4 16:53 发表
需求如下
执行某system call后会往日志文件里生成一些log
现在想把执行前后的日志文件差异部分打印出来,怎么做?

Text:iff
能不能给个例子参考一下,我的日志文件是同一个,Text::diff 好像是两个不同文件之间的比较


QUOTE:
原帖由 linhao 于 2007-12-4 17:10 发表
能不能给个例子参考一下,我的日志文件是同一个,Text::diff 好像是两个不同文件之间的比较



[Copy to clipboard] [ - ]
CODE:
#!/usr/bin/perl

use strict;
use Text::Diff;

#my ($first, $secnd) = @ARGV;
my $first = "ref.pl";
my $secnd = "ref.pl.bak";
my $diff = diff $first, $secnd, { STYPE => "table" };
print $diff;

可以先备份一下.
多谢 lonelyair   
use strict;
use Text::diff;
my $FIRST = "test1.log";
my $SECOND ="test2.log.bk";
my $DIFF = diff $FIRST,$SECOND,{ STYlE => "table" }; ;
print "$DIFF\n";

执行完上面报错如下,什么原因?

perl test.pl
Can't locate object method "diff" via package "test1.log" (perhaps you forgot to load "test1.log"?) at test.pl line 5.


QUOTE:
原帖由 linhao 于 2007-12-4 17:56 发表
use strict;
use Text::diff;my $FIRST = "test1.log";
my $SECOND ="test2.log.bk";
my $DIFF = diff $FIRST,$SECOND,{ STYlE => "table" }; ;
print "$DIFF\n";

执行完上面报错如下,什么原因?

...

看上边红色的部分,确保这个模块已经安装.
Text::diff 这个模块我已经拷贝到perl ->lib  目录下了,应该是已经装好,如果没装好,编译的时候会报的错不一样

Can't locate Text/diff.pm in @INC (@INC contains: C:\Program Files\ActiveState Perl Dev Kit 6.0 Deployment\lib\ C:/Perl/site/lib C:/
Perl/lib .) at test.pl line 2.
BEGIN failed--compilation aborted at test.pl line 2.

请教上门这个错误
Can't locate object method "diff" via package "test1.log" (perhaps you forgot to load "test1.log"?) at test.pl line 5.
怎么解决啊?


QUOTE:
原帖由 linhao 于 2007-12-5 12:23 发表
Text::diff 这个模块我已经拷贝到perl ->lib  目录下了,应该是已经装好,如果没装好,编译的时候会报的错不一样

Can't locate Text/diff.pm in @INC (@INC contains: C:\Program Files\ActiveState Perl De ...

你应该用命令行,ppm install Text:iff 来安装.不是拷贝