faezshingeri has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to replace many array element with another corresponding array element in a file, but its taking ages to execute. Is there a simpler approach ? Below is my code:
open( my $in, '<', "Test.txt") or die "cannot open Test.txt $!"; open( my $out, '>', "TestFinal.txt") or die "cannot create TestFinal $ +!"; while( <$in>) { for(my $i=2 ; $i<=$LastRowGlossary; $i++) { s/$variable[$i]/$vardescription[$i]/g; } for(my $j=2 ; $j<=$LastRowTable; $j++) { s/$COVERAGE_TYPE_CODE[$j]/$TCOVERAGE[$j]/g; s/$CVG_TEST_CRIT_CD[$j]/$TCVG_TEST_CRIT_TYP[$j]/g; } print {$out} $_; } close $in; close $out;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Replace many array element with another corresponding array element in a file
by Kenosis (Priest) on Oct 18, 2012 at 05:18 UTC | |
by faezshingeri (Initiate) on Oct 18, 2012 at 05:31 UTC | |
by Kenosis (Priest) on Oct 18, 2012 at 05:39 UTC | |
Re: Replace many array element with another corresponding array element in a file
by choroba (Cardinal) on Oct 18, 2012 at 05:55 UTC | |
by faezshingeri (Initiate) on Oct 18, 2012 at 06:09 UTC | |
by Kenosis (Priest) on Oct 18, 2012 at 06:03 UTC |
Back to
Seekers of Perl Wisdom