|Syntactic Confectionery Delight|
String replacement preparation for file comparisonby TJRandall (Sexton)
|on Apr 06, 2012 at 13:28 UTC||Need Help??|
TJRandall has asked for the
wisdom of the Perl Monks concerning the following question:
I need to compare CVS files to Oracle code extracts from our Production environment. The issue is that some of the CVS files do not declare the function (package, procedure) in the same format as the Oracle extract, which later flags the files as different when using Text:Diff.
This difference:CREATE OR REPLACE FUNCTION DC_F_COD_RANDOM_MMA RETURN VARCHAR2 IS
is one that I can safely ignore.
My approach is to open each CVS file, and check to see if it declares in the Oracle format. If not, replace the current declaration with a cleaned up Oracle one. (this is actually my first question - does this sound like a valid approach?)
So I look for the piece between 'CREATE OR REPLACE' and 'AS' or 'IS'. Inside there, I will find 'FUNCTION', 'PROCEDURE' or 'PACKAGE', and the actual name. So in the code I'm working on below, I have a function which is not in the Oracle format - so I have to change the file contents to
Is there a way to do this cleanly / easily, without all the IF/ELSE blocks that I'm building out - my current approach feels like I'm going to be sprawling quickly into something that is unmanageable.
Your thoughts / pointers / advice is GREATLY appreciated!