I think OP's problems were sufficiently pointed out. I was wondering if lexical file handles (open my $fh vs. open FILE) might be useful. What I found was that I successfully separated the input filehandle pointer from the output filehandle pointer, but the input filehandle stopped at the original eof instead of moving on through the new file contents. Could some wiser monks explain that to me?
C:\chas_sandbox>for %f in (a b c d) Do echo %f>>alpha.txt C:\chas_sandbox>echo a 1>>alpha.txt C:\chas_sandbox>echo b 1>>alpha.txt C:\chas_sandbox>echo c 1>>alpha.txt C:\chas_sandbox>echo d 1>>alpha.txt C:\chas_sandbox>perl -le "open my $fh_in, '<', 'alpha.txt'; open my $f +h_out, '>> ', 'alpha.txt';while (<$fh_in>) {chomp;print $fh_out chr(ord($_)+4); l +ast if $_ eq 'v'}" C:\chas_sandbox>type alpha.txt a b c d e f g h
In reply to Re: read from a file and write into the same file
by goibhniu
in thread read from a file and write into the same file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |