shevek: It re-opens the same file for output.
toniax: You say you are new to Perl programming, and by implication you may be new to programming in general. If so, it is well to point out a critical side-effect of your OPed program: When the file is re-opened for output, the original content of the file is destroyed. The only place the original file content still exists is in an array in your program. If your program should fail for any reason before the original content is completely processed, the output file will be left only partly full of processed data – and possibly entirely empty.
One approach to handling a situation like this (in which processed output data is intended to be held in a file with the same name as the input file) would be:
Note that error checking is vital at each stage of this process. In this way, much grief may be avoided.
In reply to Re: regular expression
by AnomalousMonk
in thread regular expression
by toniax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |