use strict; use warnings; my $buffer; open my $OUT, '>', \$buffer; print $OUT 'Some text'; close $OUT; print $buffer;