This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [PATCH] [ID 20011130.166] "in memory" file handles via scalas not documented...
authorTels <nospam-abuse@bloodgate.com>
Sat, 1 Dec 2001 10:29:11 +0000 (11:29 +0100)
committerJarkko Hietaniemi <jhi@iki.fi>
Sat, 1 Dec 2001 15:52:13 +0000 (15:52 +0000)
Message-Id: <200112010931.LAA29309@tiku.hut.fi>

p4raw-id: //depot/perl@13402

pod/perlfunc.pod

index 0271862..2b20a4b 100644 (file)
@@ -2666,6 +2666,8 @@ conversion assumes base 10.)
 
 =item open FILEHANDLE,MODE,EXPR,LIST
 
+=item open FILEHANDLE,MODE,REFERENCE
+
 =item open FILEHANDLE
 
 Opens the file whose filename is given by EXPR, and associates it with
@@ -2778,6 +2780,10 @@ argument being C<undef>:
 
 opens a filehandle to an anonymous temporary file.
 
+File handles can be opened to "in memory" files held in Perl scalars via:
+
+    open($fh,'>', \$variable) || ..
+
 Examples:
 
     $ARTICLE = 100;
@@ -2802,6 +2808,11 @@ Examples:
     open(EXTRACT, "|sort >/tmp/Tmp$$")         # $$ is our process id
        or die "Can't start sort: $!";
 
+    # in memory files
+    open(MEMORY,'>', \$var)
+       or die "Can't open memory file: $!";
+    print MEMORY "foo!\n";                     # output will end up in $var
+
     # process argument list of files along with any includes
 
     foreach $file (@ARGV) {