##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 = ; 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); }