in reply to Re^15: Question about binary file I/O
in thread Question about binary file I/O
The problem with that, though, is that the print function completely erases the rest of the file.
It won't if you use the right open mode; ie. '+<':
#! perl -sw use strict; ## Open for reading and writing open IO, '+<', 'junk.dat' or die $!; seek IO, 11, 0; print IO 'this overwrites'; close IO; __END__ C:\test>type junk.dat xxxxxxxxx xxxxxxxxx xxxxxxxxx xxxxxxxxx C:\test>junk59 C:\test>type junk.dat xxxxxxxxx this overwritesxxxxx xxxxxxxxx
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^17: Question about binary file I/O
by TheMartianGeek (Acolyte) on Mar 05, 2011 at 23:55 UTC | |
by BrowserUk (Patriarch) on Mar 06, 2011 at 08:21 UTC |