ログを解析してエラーと警告を見つけるスクリプトがあります。
そして、このログのユーザーフレンドリーな解釈を使用したいと思います。
このため、私は を使用しますnotepad
。
コードは次のとおりです。
use v5.16;
use strict;
use warnings;
use Win32::Clipboard;
use threads;
use utf8;
my $kp = Win32::Clipboard->new();
my $output = shift || "out_log.txt";
#my ($input, $output)=@ARGV;
#open my $ih, "<", $input or die "can't open input file with log\n";
open my $oh, ">", $output or die "can't open output file with log\n";
my @alls=split /\n/,$kp->Get();
for my $k(0..$#alls){
$_ = $alls[$k];
if(/^ERR.+|^WARN.+/){
print {$oh} qq(at position $k --> ).$_."\n";
}
}
my $thread =
threads->create(sub{
$SIG{INT}=sub{die"All good\n";};
qx(notepad $output);
}
);
print qq(type 'y' for quit);
do{
print "want to quit?\n>" ;
chomp;
do{
say "I will kill this thread";
$thread->kill('INT') if defined($thread);
say "and delete output";
unlink $output;
exit(0);
}if (m/y/);
}while(<>);
メモ帳を実行しているスレッドを強制終了しようとすると、落ちます。
シグナルとスレッドを使用してこれを行う方法は? 出来ますか?
そして、解決策についてのあなたのアイデアをお願いします。
ありがとう!