File content question

From: Sanjeev Sagar (sanjeev.sagar_at_eds.com)
Date: 03/30/04


To: beginners@perl.org
Date: Mon, 29 Mar 2004 16:24:58 -0600


Hello Everyone,

We have a process where several scripts write to centralized log file. I
have to retrieve a specific set of information and display in a format.
Following is a snippet of log file

=========================
<Bunch of text lines>

Variable_name Value
1.
2.
3.
4.
.
.
.
Upto 200 lines of variables and their values
************************1 row***************

<Bunch of text files>
===============================

I have to collect the variable_name and their value block of 200 lines.
Every 15 min. this output get added in file.

I am trying to write code for this but getting lost in b/w like below

#!/usr/bin/perl -w

$infile = "/tmp/test1.log";
$outfile = "/tmp/mysqltats.out";

open (INFILE, "<$infile") || die "cannot open $infile: $!\n";
open (OUTFILE, ">$outfile") || die "cannot open $outfile: $!\n";

while ( $mystring = <INFILE> ) {

        chomp $mystring;
        if ( $mystring =~ /\*+/) { next; }
        elsif ( $mystring =~ /^Variable_name/ ) { next; }

   #Here I need to store those 200 lines in an array or something but don't
know how.
}

close (OUTFILE);
close (INFILE);

system ("cat $outfile");

Any help will be highly appreciable.

Best Regards,

 <<Sagar, Sanjeev.vcf>>






Relevant Pages

  • Re: Creating directories
    ... I'm starting a bunch of applications and need to write their stdout ... to a new log file. ... Can I do that with Logger? ...
    (comp.lang.ruby)
  • Re: Yahoo got new slurper
    ... robots, I mean a bunch of new IP's popped up in the log file and it ... made my website show up in their index much faster, ...
    (alt.internet.search-engines)
  • Re: hosts.deny: how do i test to see if hosts.deny is working
    ... I should have mentioned that the format of hosts.deny file is this: ... I have put a bunch ip addresses in my hosts.deny and I'm not sure if ... I would like to know if there is a log file or some other way to ... verify that IP's that I've designated in hosts.deny are actually ...
    (comp.os.linux.setup)
  • Logging firewall hits in a specific log file
    ... Now that I have IP Masquerading up, ... bunch of firewall hits logged in the SYSLOG log files. ... specific log file ...
    (RedHat)
  • Re: How to dynamically display entries made into a growing log fil
    ... FileSystemWatcher object and in the changed event, update the display to ... does pick up events that may happen at compile time. ... To display the contents of the log file you could do a couple of different ... I want to create a windows form application, which, upon ...
    (microsoft.public.dotnet.framework.aspnet)