your attempt only opens the file for read, not write.open RECORD_NUMBER, '<', "counter_data.dat" or die; $count = <RECORD_NUMBER>; close RECORD_NUMBER; $count++ open FILE, '>', "counter_data.dat" or die; print FILE $count; close FILE;
I see most people answered along these lines. It is worth mentioning open '+<' mode too, although in that case one would have to seek as well.
In reply to Re^2: File I/O
by blazar
in thread File I/O
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |