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 -->
  #1 (permalink)  
Old 03-18-2009
SkySmart SkySmart is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 50
Perl Script issue. What am I doing wrong?

#!/usr/local/bin/perl


open (MYFILE, 'logs_report');


while (<MYFILE>) {

$rec=$_;
chomp ($rec);
@arr=split(/ /,$rec);
print $rec,"\n" if ($arr[12]!~/OK/);

open (MYF, '>data.txt');

print $rec,"\n" if ($arr[12]!~/OK/);
close (MYF);



}
close (MYFILE);


ok, here's what i'm trying to u. I'm opening the file logs_report and i'm grepping only for lines that DOES NOT have OK in it.

Now, the result i get from that grep is what I"m trying to write to a file.

How can I do that?

so pretty much, i'm trying to open up a file, read the contents of the file, pull out certain lines from that file, and the certain lines i print out, i want to write it to a file. how can i do that? also, if i want to mail the file that is written out to, is there a way to do that in perl?