Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
日志文件中的Perl脚本查找时间戳_Perl_Perl Module - Fatal编程技术网

日志文件中的Perl脚本查找时间戳

日志文件中的Perl脚本查找时间戳,perl,perl-module,Perl,Perl Module,我必须对现有的PERL脚本进行修改。由于我在PERL脚本编写方面没有经验,所以我在谷歌上搜索并做了一些更改,但这不起作用。 因此,有一部分检查文件中是否存在特定的时间戳。 代码是 while (<IN>) { if (/timestamp="(\w\w\w) (\d\d) \d\d:\d\d:\d\d (\d\d\d\d)"/ { $NowDate=$3.$Month{$1}.$2; if ( $NowDate > $Star

我必须对现有的PERL脚本进行修改。由于我在PERL脚本编写方面没有经验,所以我在谷歌上搜索并做了一些更改,但这不起作用。 因此,有一部分检查文件中是否存在特定的时间戳。 代码是

    while (<IN>) {
      if (/timestamp="(\w\w\w) (\d\d) \d\d:\d\d:\d\d (\d\d\d\d)"/ {
        $NowDate=$3.$Month{$1}.$2;
        if ( $NowDate > $StartDate ) {
          print OUT $_;
          while (1) {
            $regel=<IN>;
            if (! defined $regel) {last}
              print OUT $regel;
            }
          }
       }
  }

谁能给我一些建议。

问题是我没有通过if条件。文件中的时间戳为timestamp=“2017-02-16T13:08:34.104”您错过了模式中的小数秒。立即重试我已经输入了if条件,但出现以下错误“在串联(.)或字符串at中使用未初始化的值”。我必须使用/。伊尔汉:如果你复制了我写的东西,那就不可能了。我不知道你所说的“DoGivedtoUse/”是什么意思,虽然这个代码片段是受欢迎的,可能会提供一些帮助,但它将是如何以及为什么解决这个问题的。记住,你是在将来回答读者的问题,而不仅仅是现在提问的人!请在回答中添加解释,并说明适用的限制和假设。
if ( /timestamp="(\d\d\d\d)-(\d\d)-(\d\d)T\d\d:\d\d:\d\d\.\d\d\d"/ ) {
    $NowDate = $1.$2.$3;
    ...
}
if ( /timestamp="(\d\d\d\d)-(\d\d)-(\d\d)T\d\d:\d\d:\d\d\.\d\d\d"/ ) {
    $NowDate = $1.$2.$3;
    ...
}