CC: | mjd [...] plover.com |
Date: | Sun, 24 Dec 2006 18:32:13 -0500 |
To: | bug-Tie-File [...] rt.cpan.org |
From: | Mark Jason Dominus <mjd [...] plover.com> |
Show quoted text
> Tie::File can do in-memory access, if you really want it to.
>
> open FH, ">", \$scalar;
> tie @rec, 'Tie::File', \*FH;
It's already documented that you can supply a pre-opened filehandle.
There is a whole section of the manual titled "Tying to an
already-opened filehandle". I have attached it below for your
convenience.
I question the usefulnes of adding any material about in-memory
filehandles.
----------------------------------------------------------------
Tying to an already-opened filehandle
If $fh is a filehandle, such as is returned by "IO::File" or
one of the other "IO" modules, you may use:
tie @array, 'Tie::File', $fh, ...;
Similarly if you opened that handle "FH" with regular "open" or
"sysopen", you may use:
tie @array, 'Tie::File', \*FH, ...;
Handles that were opened write-only won't work. Handles that
were opened read-only will work as long as you don't try to
modify the array. Handles must be attached to seekable sources
of data---that means no pipes or sockets. If "Tie::File" can
detect that you supplied a non-seekable handle, the "tie" call
will throw an exception. (On Unix systems, it can detect
this.)
Note that Tie::File will only close any filehandles that it
opened internally. If you passed it a filehandle as above, you
"own" the filehandle, and are responsible for closing it after
you have untied the @array.