sivasakthi wrote:
Hi All,
Hello,
I have used the following code to calculate from log files, #!/usr/bin/perl use strict; use warnings; use File::Tail; my $file=File::Tail->new("/log/path"); my $line= undef;
You don't really need file scope for $line.
while (defined($line=$file->read))
You can limit its scope here: while ( defined( my $line = $file->read ) )
{ my ($time,$lport,$ip,$stats,$rport) = split;
The current line is in the $line variable but you are splitting the contents of the $_ variable:
my ( $time, $lport, $ip, $stats, $rport ) = split ' ', $line; If you only need the third field then you could write that as: my $ip = ( split ' ', $line )[ 2 ];
print "$ip/n";
If you want a newline at the end it is spelt "\n", not "/n".
}
John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/