in reply to Re: Redirecting/Restoring of Memory Files
in thread Redirecting/Restoring of Memory Files

Perl does have a feature of being able to open a file handle/stream on a string buffer rather than external media. There are several reasons why it is sometimes useful to treat a string as if it were a file. Three reasons that come to mind:

For more information on this feature of Perl, see open and search for the phrase "Perl scalars". I believe support has been part of the Perl core since 5.8 (which is why I presume Disciplus tested that version - which is really old). See also IO::Scalar and IO::String. IO::Scalar can be used to bring support for in memory/scalar backed file handles to even earlier versions of Perl.

  • Comment on Re^2: Redirecting/Restoring of Memory Files

Replies are listed 'Best First'.
Re^3: Redirecting/Restoring of Memory Files
by flexvault (Monsignor) on Jun 25, 2015 at 18:42 UTC

    Thank you ELISHEVA,

    It's always good to learn something new, and doing I/O to a string is new to me. Since I use 'diff' a lot in *nix and also have my own editor for working with development files, I'm not sure how often I would use it.

    As far as your 'black hole', you'll see the same with a regular file. I have prematurely closed a file handle and then later added a 'print' statement. No error, no warning and no data. Also if you save a file handle to disk and then retrieve, you need some 'Perl magic' to get it to be valid file handle again.

    Thanks for the updated information...Ed

    Regards...Ed

    "Well done is better than well said." - Benjamin Franklin