Quote:
Originally Posted by pludi
Code:
#!/usr/local/bin/perl
open (MYFILE, 'logs_report');
open (MYF, '>data.txt');
while ($rec = <MYFILE>) {
chomp($rec);
@arr = split(/ /,$rec);
if ($arr[12] !~ /OK/) {
print $rec, "\n";
print MYF $red, "\n";
}
}
close (MYF);
close (MYFILE);
This is probably what you want. The way you wrote it, you'd overwrite your data.txt every time you find something, plus opening and closing repeatedly in a loop can be quite I/O cost intensive.
And the next time you post listings or source, enclose it in [ code][/code ] tags (sans the spaces), to preserve formatting for readability.
|
thank you. sorry for not including the codes. would you happen to know how to include a code in ur code that will email the file to a set of email addresses? i mean the file that is written to? your help or input is greatly appreciated. thanks