Sanjeev Sagar wrote: > > Hello Everyone, Hello,
> 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 ^^^^^^^^^^^ Lost in what? > #!/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; } Your regular expression says "find one or more '*' characters anywhere in $mystring" however finding one is the same as finding one or more. if ( $mystring =~ /\*/) { next; } > elsif ( $mystring =~ /^Variable_name/ ) { next; } You could do it like this: next if $mystring =~ /\*/ or $mystring =~ /^Variable_name/; > #Here I need to store those 200 lines in an array or something but don't > know how. push @an_array, $mystring; > } > > close (OUTFILE); > close (INFILE); > > system ("cat $outfile"); Why not just 'print "$mystring\n";' inside the while loop. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>