您能否提供有关以下perl代码段的详细说明.我从谷歌得到了一些想法,但仍有很多基本的混乱.如果你可以提供小笔记,那将是很有帮助的
$exit_value = $? >> 8;
$signal_num = $? & 127;
$dumped_core = $? & 128;
Run Code Online (Sandbox Code Playgroud) 要求 - 我的文件名称为"Rajesh.1202242219".数字只不过是日期" date '+%y''%m''%d''%H''%M'"格式.现在我正在尝试编写一个perl脚本来从文件名中提取数字并与当前系统日期和时间进行比较,并根据此比较的输出,使用perl打印一些值.
做法:
从文件名中提取数字:
if ($file =~ /Rajesh.(\d+).*/) {
print $1;
}
Run Code Online (Sandbox Code Playgroud)
将此时间转换为perl中的可读时间
my $sec = 0; # Not Feeded
my $min = 19;
my $hour = 22;
my $day = 24;
my $mon = 02 - 1;
my $year = 2012 - 1900;
my $wday = 0; # Not Feeded
my $yday = 0; # Not Feeded
my $unixtime = mktime ($sec, $min, $hour, $day, $mon, $year, $wday, $yday);
print "$unixtime\n";
my $readable_time = localtime($unixtime); …Run Code Online (Sandbox Code Playgroud) 我在我的perl脚本中使用以下类型的脚本并期望在第1行进入.我收到一些错误,如下所示; 任何帮助?
plz忽略perl变量....
错误消息 - sed:-e表达式#1,字符22:命令后的额外字符
# Empty file will not work for Sed line number 1
`"Security Concerns Report" > $outputFile`;
`sed '1i\
\
DATE :- $CDate \
Utility accounts with super access:- $LNumOfSupUserUtil \
Users not found in LDAP with super access: - $LNumOfSupUserNonLdap\
' $outputFile > $$`;
`mv $$ $outputFile`;
}
Run Code Online (Sandbox Code Playgroud) 我想返回正确的值$message_all,但在给定的场景中它会变回空白.有什么建议?
processing()
print "message_all = $message_all";
sub processing
{
log ( " Some message");
}
sub log
{
my $text = shift;
my $message_all .= $text;
return "$message_all";
}
Run Code Online (Sandbox Code Playgroud)