my $fh = do {local *FH}; my $file = "foo.txt"; open ($fh, "> $file") or die "Cannot write '$file': $!"; print $fh "Hello world\n";