Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: how to modify foreach

by poj (Abbot)
on Jun 08, 2018 at 11:35 UTC ( [id://1216188]=note: print w/replies, xml ) Need Help??


in reply to Re^2: how to modify foreach
in thread how to modify foreach

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

Replies are listed 'Best First'.
Re^4: how to modify foreach
by Anonymous Monk on Jun 08, 2018 at 12:40 UTC

    you make my day !!! thank you everyone for your help and have a nice week end
    OliverR

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1216188]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2024-04-20 03:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found