我正在尝试编写一个Perl脚本来解析日志,其中每行第二个值是日期.该脚本包含三个参数:输入日志文件,开始时间和结束时间.开始和结束时间用于解析每行之间的某个值,该值介于这两次之间.但为了正确运行这个,我将开始和结束时间转换为纪元时间.我遇到的问题是将循环'i'值转换回正常时间以与日志文件进行比较.运行后localtime($i)我打印了值,只看到打印的参考不是实际值.
这是我到目前为止的脚本(这是一项正在进行的工作):
#!/usr/bin/perl
use strict;
use warnings;
use Time::Local;
use Time::localtime;
use File::stat;
my $sec = 0;
my $min = 0;
my $hour = 0;
my $mday = 0;
my $mon = 0;
my $year = 0;
my $wday = 0;
my $yday = 0;
my $isdst = 0;
##########################
# Get the engine log date
##########################
my $date = `grep -m 1 'Metric' "$ARGV[0]" | awk '{print \$2}'`;
($year,$mon,$mday) = split('-', $date);
$mon--;
#########################################
# Calculate the …Run Code Online (Sandbox Code Playgroud) 在Perl中,我试图读取一个日志文件,并且只打印具有两个特定时间之间的时间戳的行.时间格式为hh:mm:ss,这始终是每个日志的第三个值.例如,我会搜索在12:52:33到12:59:33之间的行
我是Perl的新手,并且不知道采取哪条路线来开始编程.我很确定这会使用某种类型的正则表达式,但对于我的生活,我甚至无法理解那将是什么.有人可以帮助我这个.
另外,为了使这更加困难,我必须使用核心Perl模块执行此操作,因为我的公司不允许我使用任何其他模块,直到它们经过测试和验证,对脚本可能没有任何系统的不良影响与...相互作用.
我已经看到成员函数在它们所属的类内部以及类外部编写了一个函数原型.我只使用第一种方法编程,但想知道使用另一种或仅仅是个人偏好是否更好?
有没有办法让Ant创建运行时shell或批处理运行时脚本,而不必自己手动创建脚本.
它类似于链接文本的功能
有谁知道计算机集群如何用于日常应用,例如视频游戏?
我想构建一个可以在群集上运行应用程序的计算机群集,这些应用程序不是专门为计算机群集设计的,但仍然可以看到性能提升.一个用途是用于视频游戏,但我也想利用增加的计算能力来运行大型虚拟机网络.
我目前正在计划创建一个基本的网络游戏,但我们决定承担使用C#客户端制作C++服务器的任务.我知道这可能是一项艰巨的任务,但我想知道是否有任何关于实现这一目标的建议.
对不起,我没有比这更多的信息了.我们刚刚开始,只是想确保在我们的时间跨度内实现这一目标.
我该如何解决以下错误:
readline() on unopened filehandle UPPER at faStat2 line 86.
Run Code Online (Sandbox Code Playgroud)
在以下代码中?
#!/usr/bin/perl
use strict;
use warnings;
...
my $cmd = $0;
$cmd =~ s#.*/##;
($#ARGV > 0) || die "Usage $cmd <tibcoUpperMDLog> <tibcoLowerMDLog> <outFile>\n\n";
open(my $UPPER, $ARGV[0]) || die "Unable to open $ARGV[0]\n";
open(my $LOWER, $ARGV[1]) || die "Unable to open $ARGV[1]\n";
...
while ($msg = <UPPER>) { getUpperBusTimeStampAndBatchSize(\$msg); } #This is the line that the error is complaning about
Run Code Online (Sandbox Code Playgroud) 在Perl中,我尝试$adjSendTime使用以下代码将包含毫秒纪元时间变量的变量转换为标准约定:
$timeLabel = sprintf("%02d:%02d:%02d", (($adjSendTime/3600000) % 24), (($adjSendTime/60000) % 60), $currentSecond);
Run Code Online (Sandbox Code Playgroud)
问题在于,无论何时达到第59秒,时间的一小部分时间都将高于应有的时间.输出看起来像
11:58:57
11:58:58
11:59:59
11:59:00
11:59:01
Run Code Online (Sandbox Code Playgroud)
计算$adjSendTime如下:
# Determine number of hours between local time and UTC.
# This code is needed to compare timestamps in local time with those in epoch time.
# This code only works in time zones with current time less than UTC time.
@timeArray = gmtime();
$utcHour = $timeArray[2];
@timeArray = localtime();
$localHour = $timeArray[2];
# calculate number of milliseconds …Run Code Online (Sandbox Code Playgroud)