打开到标量的文件句柄
? ? ? ? ? ?As a special case the three-argument form with a read/write mode and the third argument being "undef":
?
? ? ? ? ? ? ? ?open(my $tmp, "+>", undef) or die ...
?
? ? ? ? ? ?opens a filehandle to an anonymous temporary file. ?Also using "+<" works for symmetry, but you really should consider writing something to the temporary
? ? ? ? ? ?file first. ?You will need to seek() to do the reading.
?
? ? ? ? ? ?Since v5.8.0, Perl has built using PerlIO by default. ?Unless you've changed this (such as building Perl with "Configure -Uuseperlio"), you can open
? ? ? ? ? ?filehandles directly to Perl scalars via:
?
? ? ? ? ? ? ? ?open($fh, ">", \$variable) || ..
?
? ? ? ? ? ?To (re)open "STDOUT" or "STDERR" as an in-memory file, close it first:
?
? ? ? ? ? ? ? ?close STDOUT;
? ? ? ? ? ? ? ?open(STDOUT, ">", \$variable)
? ? ? ? ? ? ? ? ? ?or die "Can't open STDOUT: $!";