这是我要解析的日志:
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;
}
这是错误:
/data/noc/startup/logs/pats.11-01-11.txt 不能在./log_grap第17行第1行使用字符串(“06:27:54 / data / noc / startup / start”)作为符号引用,而使用“strict refs”。
答案 0 :(得分:7)
添加分号:
while (<FILE>) {
my $line = $_;
print $line; # semicolon!
sleep 1;
}