It looks like you may have copy/pasted the line contituation character +
$_ = "" unless ($_ =~ m/"ENABLED","OLTP",/ && $_ =~m/^GREP
+/ );
Should be one line
$_ = "" unless ($_ =~ m/"ENABLED","OLTP",/ && $_ =~m/^GREP/ );
Have a read of File::Find
#!/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 (<IN>){
next if /SYS/;
next unless m/^GREP/ && m/"ENABLED","OLTP",/;
print OUT $_;
#print $_;
++$outcount;
last;
}
close IN;
++$filecount;
}
poj