finding set of records from log using perl.

Here is a log file. We need to create separate file for each set of record. Record should be extracted using some specific pattern as below.

open (FILE, "ab.txt" ) || die "can't open file!";
my $xml;
my $reset=0;
my $SD=1;
while ()

if ( m/V\/\/\w+\sJOB \(/){
if($reset != 0)
{
close OUT;
}
open(OUT, ">JOBS_$SD.txt") || die ("File could not found! $i");

$SD++;
$reset=1;
}

print OUT $_;

}

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: