in reply to if/while/else problem
In addition, you should really be using the three-argument form of open and testing to see if your open operations fail. Fixing the block structural issues mentioned above, perhaps you mean:
system "rm file2"; open(FILE2, ">", "file2") or die "Opening output failed: $!"; my $file = "file"; if ( -e $file and -s $file ){ open(MYINPUTFILE, "<", $file) or die "Opening input $file failed: +$!"; while(<MYINPUTFILE>) { my($line) = $_; chomp($line); print FILE2 "$line\n"; print FILE2 "you need to do this\n"; print FILE2 " \n"; } } else { print FILE2 "There is nothing to do\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: if/while/else problem
by ikegami (Patriarch) on Mar 25, 2009 at 20:13 UTC | |
|
Re^2: if/while/else problem
by ddrew78 (Beadle) on Mar 25, 2009 at 20:53 UTC |