NateTut has asked for the wisdom of the Perl Monks concerning the following question:
Here is an example Input File:while($Template =~ /\n(.*%%$FindWhat.*%%.*\n)/i) { my $Original_Line = $1; my $ReplacementString = ''; my $First = true; # # Replace Each Column # foreach my $Column (@Columns) { my $New_Line = $Original_Line; foreach my $Field (keys(%$Column)) { $New_Line =~ s/%%$Field.*%%/$Column->{$Field}/i; } $ReplacementString = $ReplacementString . $New_Line; }
/* ------------------------------------------------------------------- +------------------------------------------------ ** %%TableName%%.Fl ** ------------------------------------------------------------------- +------------------------------------------------ ** FastLoad Script for %%TableName%% ** ------------------------------------------------------------------- +------------------------------------------------ ** Generated by LoadGen ** ------------------------------------------------------------------- +------------------------------------------------ ** What | Who | When | Why ** ------------------------------------------------------------------- +------------------------------------------------ ** 1.00 | %%Author_Initials%% | %%Date%% | Original Version ** ------------------------------------------------------------------- +------------------------------------------------ ** | | | ** ------------------------------------------------------------------- +------------------------------------------------ ** | | | ** ------------------------------------------------------------------- +------------------------------------------------ */ .Show Versions; .Sessions %%Sessions%%; .LogOn %%TPID%%/%%User%%,%%Password%%; Database %%StagingDB%%; Drop Table ET_%%TableName%%; Drop Table UV_%%TableName%%; Drop Table %%TableName%%_Stage; Create Set Table %%TableName%%_Stage , No FallBack , No Before Journal , No After Journal , CheckSum = High ( %%Column_Name_Comma%% Varchar(%%Column_Size%%) ) Primary Index ( %%Primary_Index_Column_Comma%% ) ; .Set Record %%Record_Type%%; Begin Loading %%TableName%%_Stage Errorfiles ET_%%TableName%%, UV_%%TableName%%; Help Table %%TableName%%_Stage; Define File = %%Data_Dir%%%%Data_FileName%%; Show; ErrLimit %%ErrLimit%%; Insert Into %%TableName%%_Stage Values ( :%%Column_Name_Comma%% ); End Loading; .LogOff;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem Replacing Previously Found String
by ikegami (Patriarch) on Nov 17, 2004 at 05:31 UTC | |
|
Re: Problem Replacing Previously Found String
by diotalevi (Canon) on Nov 16, 2004 at 23:17 UTC | |
by NateTut (Deacon) on Nov 16, 2004 at 23:34 UTC | |
by diotalevi (Canon) on Nov 16, 2004 at 23:52 UTC | |
by NateTut (Deacon) on Nov 17, 2004 at 16:47 UTC | |
|
Re: Problem Replacing Previously Found String
by TedPride (Priest) on Nov 17, 2004 at 09:18 UTC | |
by NateTut (Deacon) on Nov 17, 2004 at 16:49 UTC |