use Text::Diff;
for($count = 0; $count <= 1000; $count++){
my $data_dir="archive/oswiostat/oracleapps.*dat";
my $data_file= `ls -t $data_dir | head -1`;
while($data_file){
print $data_file;
open (DAT,$data_file) || die("Could not open file! $!");
$stats1 = (stat $data_file)[9];
print "Stats: \n";
@raw_data=<DAT>;
close(DAT);
print "Stats1 is :$stats1\n";
sleep(5);
if($stats1 != $stats2){
@diff = diff \@raw_data, $data_file, { STYLE => "Context" };
$stats2 = $stats1;
}
print @diff || die ("Didn't see any updates $!");
}
}
는 출력 : 통계가 누락 및 해결 방법을하는 이유Perl에서 어떻게 디렉토리를 변경하여 볼 수 있습니까?
는$ perl client_socket.pl
archive/oswiostat/oracleapps.localdomain_iostat_12.06.28.1500.dat
Stats:
Stats1 is :
Didn't see any updates at client_socket.pl line 18.
당신이 말해 줄 수 있습니까?
나는 그것이 실제로 실행 한 코드라고 생각하지 않습니다. $ data_file은 파일의 이름 뒤에 개행 문자가 있기 때문에 open이 실패하여 죽을 것이다. 'chomp'로 해결할 수 있습니다. 수많은 다른 문제가 있지만 코드가 아닌 것에 대해 논평해야 할 점은 무엇입니까? 나는 강력하게'use strict; 경고를 사용하고 오류를 수정하십시오. – ikegami
파일은 "archive/oswiostat/oracleapps.localdomain_iostat_12.06.28.1500.dat"로 주먹 줄에 인쇄되어 있습니다. – VeerM
아니요, 아카이브/oswiostat/oracleapps.localdomain_iostat_12.06.28.1500.dat가 있습니다. \ n "' – ikegami