Perl respects the various access modes in open for
strings, so you can specify that the strings be opened as read-only,
with truncation, in append mode, and so on:
open($fh, "<", \$string); # read only
open($fh, ">", \$string); # write only, discard original contents
open($fh, "+>", \$string); # read and write, discard original contents
open($fh, "+<", \$string); # read and write, preserve original contents
These handles behave in all respects like regular filehandles, so all
I/O functions work, such as seek,
truncate, sysread, and friends.