Hello Hippo and many thanks for your help. here is what i have done : replace
##merge data after filtering sub singlefile { my ( $file,$out) = @_; #open file open(FILE, $file) or die ("error occured while opening file"); #create list from file my @save = <FILE>; close(FILE); #empty table rows which do not meet criteria foreach (@save){ $_ = "" unless ($_ =~ m/"ENABLED","OLTP",/ && $_ =~m/^GREP/ ); $_ = "" if ($_ =~m/SYSMAN/|| m/SYS/); chomp $_; } #open output file, add data, close open(FILE, ">>OLTP.txt") or die ("error occured while opening file + OLTP.txt"); foreach (@save){ print FILE $_."\n" if ($_); } close(FILE); }
by
##merge data after filtering sub singlefile { my ( $file,$out) = @_; #open file open(FILE, $file) or die ("error occured while opening file"); #create list from file my @save = <FILE>; close(FILE); #empty table rows which do not meet criteria my $keep = ''; foreach (@save){ $_ = "" unless ($_ =~ m/"ENABLED","OLTP",/ && $_ =~m/^GREP +/ ); $_ = "" if ($_ =~m/SYSMAN/|| m/SYS/); if ($_) { $keep = $_; last; } } open(FILE, ">>OLTP.txt") or die ("error occured while opening +file OLTP.txt"); print FILE $keep if $keep; close(FILE); }
and the result is that i got only a file with only the header "User script,Serveur Name,Instance Name,Date of script,Serveur Name2,Instance.... and nothing else. if you want to give me a mail, i can send you some data to check. thank again OliverR
In reply to Re^2: how to modify foreach
by Anonymous Monk
in thread how to modify foreach
by OliverR
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |