I have Oracle files that I need to compare with CVS files, but the problem is that there are many files that I want to ignore in the first line (s) as part of the diff. I want to run a script that opens each file and replaces the contents of the file so that the final output replaces 'CREATE OR REPLACE PACKAGE "TRON"."SOME_PACKAGE" IS'with 'CREATE OR REPLACE PACKAGE SOME_PACKAGE IS'. The problem I am facing is that the statement can span multiple lines, so I have to consider a type situation .'CREATE OR REPLACE "TRON"."SOME_PACKAGE"
IS'
My approach (since this is part of Jenkins' job) is to iterate over all the files in the workspace, modifying any files that meet these criteria. Then I can use my existing Perl script, which uses File::Compareand Text::Diff::Table.
I tested the Zaid solution with little success, as it still has no problems with scripts where the command line spans multiple lines. (my changes):
use strict;
use warnings;
use Tie::File;
use Data::Dumper;
my @array;
tie @array, 'Tie::File', 'c:\cb_k_check_recon_mma.sps' or die "Unable to tie file";
my %unwanted = map { $_ => 1 }
map { $_-1..$_-4, $_, $_+2 .. $_+4 }
grep { $array[$_] =~ /^CREATE.*[IS|AS]$/ }
0 .. $#array ;
print Dumper \%unwanted;
@array = map { $array[$_] } grep { ! $unwanted{$_} } 0 .. $#array;
print Dumper \@array;
untie @array;
source
share