Perl Can';t使用字符串(";XXX";)作为符号ref,而";严格参考;使用中
这是我试图分析的日志:Perl Can';t使用字符串(";XXX";)作为符号ref,而";严格参考;使用中,perl,Perl,这是我试图分析的日志: 06:27:54 /data/noc/startup/startup_ptf_pats.sh startup initiated by waljoh @ Tue Nov 1 06:27:54 EDT 2011 06:27:54 /data/noc/startup/startup_ptf_pats.sh verifying that engine is change controlled 06:27:54 /data/noc/startup/check_chan
06:27:54 /data/noc/startup/startup_ptf_pats.sh startup initiated by waljoh @ Tue Nov 1 06:27:54 EDT 2011
06:27:54 /data/noc/startup/startup_ptf_pats.sh verifying that engine is change controlled
06:27:54 /data/noc/startup/check_change_controlled_files.sh all change controlled commands files are in synch
06:27:54 /data/noc/startup/check_today_is_holiday.sh Today is NOT a holiday
06:27:54 /data/noc/startup/check_ntpq.sh 159.79.35.42 time offset (0) is below 100
这是我写的剧本:
#!/usr/bin/perl
use warnings;
use strict;
my $todays_date = `/bin/date +%m-%d-%y`;
chomp $todays_date ;
my $grabDIR = "/data/noc/startup/logs/";
my $grabFILE = "pats." . "$todays_date" . ".txt";
print "$grabDIR$grabFILE\n" ;
my FILE;
open (FILE, "more $grabDIR$grabFILE | ");
while (<FILE>) {
my $line = $_;
print $line
sleep 1;
}
#/usr/bin/perl
使用警告;
严格使用;
my$todays_date=`/bin/date+%m-%d-%y`;
吃$todays\u date;
my$grabDIR=“/data/noc/startup/logs/”;
我的$grabbile=“pats.”。“$todays\u date”。“.txt”;
打印“$grabDIR$grabFILE\n”;
我的档案;
打开(文件“more$grabDIR$grabbile |”);
而(){
我的$line=$\ux;
打印$line
睡眠1;
}
这就是错误:
/data/noc/startup/logs/pats.11-01-11.txt
无法使用字符串(“06:27:54/data/noc/startup/start”)作为符号ref,而在/log_图第17行第1行使用“strict refs”
添加分号:
while (<FILE>) {
my $line = $_;
print $line; # semicolon!
sleep 1;
}
while(){
我的$line=$\ux;
打印$line;#分号!
睡眠1;
}
print语句后缺少分号。是否有更优雅的方式获取日期?是否有更好的方式打开文件-我是否应该将“更多”与管道一起使用请单独提问。