Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
So you see there is lot of repetition.Is there any way so that I just make the handle point to other file ? something like this :$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 .. }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how can i use one handle for multifple files
by fruiture (Curate) on May 15, 2003 at 11:09 UTC | |
by hacker (Priest) on May 15, 2003 at 11:15 UTC | |
by bart (Canon) on May 15, 2003 at 13:04 UTC | |
by Skeeve (Parson) on May 15, 2003 at 11:37 UTC | |
by rob_au (Abbot) on May 15, 2003 at 12:31 UTC | |
by BrowserUk (Patriarch) on May 15, 2003 at 13:06 UTC | |
|
Re: how can i use one handle for multifple files
by jaa (Friar) on May 15, 2003 at 11:18 UTC |