in reply to Writing to a file handle not attached to a file?
For completeness, you should also know about IO::String, and IO::Stringy (from which you would use IO::Scalar).