The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 03-18-2009
KevinADC KevinADC is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2008
Posts: 731
Similar to my reply in your other thread that I think you didn't read. Assumes same example data from that thread.

This should be more efficient and maybe more accurate:

Code:
#!/usr/local/bin/perl
use strict;

open (MYFILE, 'logs_report') or die "$!";
open (MYF, '>data.txt') or die "$!";

while (my $rec = <MYFILE>) {
    next if ($rec =~ /STATE: OK/) {
    print MYF $rec;
}
close (MYF);
close (MYFILE);
Pludis code has a small typo, it has $red where it should be $rec.