$outFile = "tmp.txt"; $outFile1 = "tmpo.txt"; open FILE, "> $outFile" or die "Cannot open file: $!"; open TEMPFILE, "> $outFile1" or die "Cannot open file: $!"; $test = "TRUE"; printf FILE "\t%s", "connect("; printf FILE "\t%s", "parameter("; .. .. #100 lines of similar code here .. if($test =~ /\bTRUE\b/){ printf FILE "\t%s", "connect("; printf FILE "\t%s", "parameter("; .. .. #100 lines of similar code here .. }elsif($test =~ /\bFALSE\b/){ printf TEMPFILE "\t%s", "connect("; printf TEMPFILE "\t%s", "parameter("; .. .. #100 lines of same code here .. } #### $outFile = "tmp.txt"; $outFile1 = "tmpo.txt"; open FILE, "> $outFile" or die "Cannot open file: $!"; $test = "TRUE"; printf FILE "\t%s", "connect("; .. .. #100 lines of similar code here .. if($test =~ /\bTRUE\b/){ FILE = $outfile; }elsif ($test =~ /\bFALSE\b/){ FILE = $outfile1; } printf FILE "\t%s", "connect("; printf FILE "\t%s", "parameter("; .. .. #100 lines of similar code here .. }