use warnings; use strict; my $read_memfile = <<'EOF'; one two three EOF open my $mem_fh, '<', \$read_memfile; print $_ while(<$mem_fh>); close $mem_fh; my $write_memfile; open my $mem_wfh, '>', \$write_memfile; print $mem_wfh "hello, world!\n"; close $mem_wfh; open my $str_fh, '<', \$write_memfile; print $_ while (<$str_fh>); close $str_fh; __END__ one two three hello, world!