1) You are using "+>>" which is opening for appending. That means your program is positioned at the end of the file and consequently is finished before it really could start.
2) Lets say you find the line. You add 1 to it and write the line out again. But that write would necessarily store the new line BEHIND the old line overwriting anything behind it. You could prevent this by remembering where the line started and doing a seek() to that position before writing. But imagine you value was 99. After adding 1 to it there is a character more to fit into the file. Result: The first character on the following line will be overwritten
So don't try to change a text file by writing into it. Write a new file and rename it to the old name. Check out perlrun and look at the switches -i and -p. Especially -i, it gives a few examples of in-place editing
In reply to Re: replace field
by jethro
in thread replace field
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |