From: Ron McKeever [mailto:[EMAIL PROTECTED]
Sent: Monday, December 05, 2005 11:50 AM
To: [email protected]
Subject: Skip then print
Hello,
I would like to skip the first ten lines of output from tail, then print
any new records matching my array, but I seem to be stuck, below will
run but nothing prints:
tail /var/log/messages is piped to it...
#!/usr/bin/perl
my @names = ("nb","tp","ape","berry","jab");
my $log = "/local/tp/tp";
#skip first ten
@array = ( 1 .. 10 );
while ($line = <>) {
foreach $number ( @array ) {
($mo, $day, $tm, $host, $proc, @data) = split(" ", $line);
foreach my $i (@names){
print "Seen on ". localtime() .": $line" if $host =~ /$i/;
}
}
}
Thanks,
Rob
This may help ....
while ($line = <>) {
next if $. <= 10;
...
}
Don't know about the split... I "assume" the data fields are separated
by a single space(?). Plus I only see the last 10 records with your
construct and I split the 10 records 10 times each....
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>