Hi All ,

          Thanks to you all for the inputs . I have created the following
script :

use warnings;
use strict;
use File::Slurp qw(read_file);
use constant LIMIT => 3;    ## Number of lines wanted
use constant UPPERLIMIT => 9;

open (OUTFILE, '>','d:\perl\OUTPUT.TXT');

#my $file = $ARGV[0];

my $filename = 'LOGFILE';

open(FH, '<', $filename) or die $!;

my @lines = read_file($filename);

for ( 0 .. $#lines ) {
    if ( $lines[$_] =~ m{\b(VERIFICATION_FAILED)\b}i ) {
     print "$_\n";
         print $lines[$_];
       print OUTFILE join " " => '*', @lines[ $_ - LIMIT .. $_ + UPPERLIMIT
], $/;
    }
elsif ($lines[$_] =~ m{\bfatal\b}i)
{
        print OUTFILE join " " => '*', @lines[ $_ - LIMIT .. $_ +
UPPERLIMIT ], $/;
}
elsif ($lines[$_] =~ m{\b'Exception Severity: 1'\b})
{
        print OUTFILE join " " => '*', @lines[ $_ - LIMIT .. $_ +
UPPERLIMIT ], $/;
}
elsif ($lines[$_] =~ m{\bstop\b}i)
{
        print OUTFILE join " " => '*', @lines[ $_ - LIMIT .. $_ +
UPPERLIMIT ], $/;
}
elsif ($lines[$_] =~ m{\bfail\b}i)
{
        print OUTFILE join " " => '*', @lines[ $_ - LIMIT .. $_ +
UPPERLIMIT ], $/;
}
else
{
print " No Errors found \n";
}

Please review if the above code seems ok .

Also want to know how to get this to UI(html page) interface for example a
html page which has a browse button to select the log file and it displays
the output parsing through the logic any module which this does or what you
suggest.

Any pointers for UI interface or any book I can refer would be helpful.


Thanks,



On Sat, Apr 13, 2013 at 9:20 PM, Asad <asad.hasan2...@gmail.com> wrote:

> Hi All ,
>
>          Greetings !
>
>        I have completed O'Reily first book Learning Perl . Started writing
> small perl programs . However I basically do log file analysis , hence was
> thinking is there any perl code around in any of the book or if anyone
> already developed for the following requirement :
>
> Nowadays I manually read the log files to read the errors which are either
> fatal or warning or ignorable . The purpose is I want to develop a web page
> as in I upload this log file and it searches for those keywords (fatal or
> warning or ignorable) and if found those keywords display the 10line before
> it and after it .
>
> Please share your thoughts. Unable to start .
>
> Thanks,
> --
> Asad Hasan
> +91 9945666911
>



-- 
Asad Hasan
+91 9945666911

Reply via email to