/*Line 1 Line 2 Line 3 dbms out put string Line 4 */ #### #!/usr/bin/perl use File::Find; use File::Basename; use strict; use English; # to get program name use Cwd; #use warnings; # Variables definitions my $match_param = "DBMS_output.put_line"; my $ignore_parameter = "/*"; undef my @nocomment_array; # array for not commented line undef my @comment_array; # array for commented line undef my @file_list; undef my @filenames; # list of filenames which contains matching parameter my $file_list_ref; my $dir = cwd; #current working directory @ARGV = $dir unless @ARGV; find(\&process_file,@ARGV); foreach my $file(@$file_list_ref) { next if $file =~ m/$PROGRAM_NAME/i ; chomp($file); open(FH,"<$file") or die "Couldn't open $file for reading: $!\n"; my $line = 0; while() { chomp $_; $line = $line +1; if (($_=~ m/$match_param/i) && ($_ !~ m/\s*--\s*$match_param/i)|| ($_=~ m/$match_param/i) && ($_ !~ m/$ignore_parameter\s*$match_param/i)) { push(@nocomment_array,"$line\t$_\n"); } } if (@nocomment_array) { push(@filenames,"$file\n") if defined $nocomment_array[0]; print "\n$file\n" if defined $nocomment_array[0]; print @nocomment_array if defined $nocomment_array[0]; } undef @nocomment_array; } my $count = scalar(@filenames); print "\n###################################\n"; print "List of $count files in the above output\n"; print "###################################\n"; print @filenames; # Print only the filenames (the whole directory path) # # process_file() subroutine: Processes all files of a directory recursively # sub process_file() { next unless !-d $File::Find::name; # skips directory my $temp = $File::Find::name; chomp($temp); my $file_name = basename($temp); # strips filename if ($file_name =~ m/.sql$/) { push(@file_list,$temp); } $file_list_ref = \@file_list; } # end of process_file()