首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

击开到标量的文件句柄

2013-11-08 
打开到标量的文件句柄? ? ? ? ? ?As a special case the three-argument form with a read/write mode and

打开到标量的文件句柄

? ? ? ? ? ?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: $!";


热点排行