in reply to How to share a file in memory instead of hard disk

I don't know if this works on Windows, but how about using the often discussed "using a variable as a filehandle".
#!/usr/bin/perl #Do you want to use a perl variable as if it were a file? #Previous versions of perl had IO::Stringy and IO::Scalar for that. #Perl 5.8 with PerlIO has it natively. Just use a reference to #the scalar in the filename slot of open. my $foo = ''; open FILEHANDLE, '+>', \$foo or die $!; print FILEHANDLE "Contents of File"; seek(FILEHANDLE,0,0); my @contents = <FILEHANDLE>; close FILEHANDLE or die $!; print 'From $foo: ', $foo, $/; print 'From file read: ', @contents, $/;

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re^2: How to share a file in memory instead of hard disk
by davido (Cardinal) on Aug 27, 2004 at 14:30 UTC

    How do you then share that memory with other processes? I don't think that's possible with the "in-memory filehandle" trick you're using.


    Dave