如何使用Perl解析Apache日志中的日期/时间?
Apache日志中的日期/时间示例:
[5月20日星期二13:23:17]
答案 0 :(得分:2)
输出是自纪元以来的秒数,
use Time::Piece;
my $str = "[Tue May 20 13:23:17 2014]";
my $t = Time::Piece->strptime($str, "[%a %B %d %H:%M:%S %Y]");
print $t->epoch, "\n";
# print $t, "\n"; check if correctly parsed