my $foo = ""; open BAR, '>', \$foo; print BAR "Test test"; close BAR; print $foo;