in reply to Newby question
Nowadays it is customary to use the more secure 3 argument variant of open with a lexical filehandle. Also, you do not have to double quote your variables, unless you want to interpolate them into a string.
andopen my $READFILE, '<', $infile or die "Can not open $infile for parsi +ng: $!" ;
open my $WRITEFILE, '>', $outfile or die "Can not open new replacement + file: $outfile. $!";
Your loop will then be written as follows:
while (<$READFILE>) { # do something to $_ print $WRITEFILE $_ ; }
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
My blog: Imperial Deltronics
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Newby question
by Parmenides (Novice) on Aug 05, 2012 at 08:09 UTC | |
by Old_Gray_Bear (Bishop) on Aug 05, 2012 at 10:44 UTC | |
by Parmenides (Novice) on Aug 08, 2012 at 04:57 UTC |