$_ = "" unless ($_ =~ m/"ENABLED","OLTP",/ && $_ =~m/^GREP +/ ); #### #!/usr/bin/perl use warnings; use strict; use Cwd; use File::Find; # variables my $outfile = 'OLTP.txt'; my $pattern = qr/option/; # opening output file and adding the header on first row my $header = join ',',('User script', 'Serveur Name','Instance Name','Date of script', 'Serveur Name2','Instance Name2', 'ADVANCED_COMPRESSION~HEADER','TABLE_COMPRESSION~HEADER',2,'count', 'DATA_DICTIONARY_VIEW','TABLE_OWNER','TABLE_NAME', 'PARTITION_NAME','COMPRESSION','COMPRESS_FOR'); open OUT, '>',$outfile or die ("Could not create outfile '$outfile' : $!"); print OUT "$header\n"; # process files my $filecount = 0; my $outcount = 1; find(\&process, getcwd ); print " $filecount files scanned $outcount lines written to $outfile\n"; close OUT; sub process { my $file = $File::Find::name; return if -d $file; return unless /$pattern/ && /\.csv$/i; # scan file open IN, '<',$file or die ("Could not open '$file' : $!"); print "File : $file\n"; while (){ next if /SYS/; next unless m/^GREP/ && m/"ENABLED","OLTP",/; print OUT $_; #print $_; ++$outcount; last; } close IN; ++$filecount; }