open(my $fh, ">", \$variable); print $fh "foo"; # "foo" steht jetzt in $variable