You could tie the filehandle to a scalar, implementing the READLINE, GETC, and READ methods appropriately. See Tying Filehandles. (I thought there must be a CPAN module to do this—sort of the converse of Tie::File—but a cursory search didn't find it.)
in reply to Re: Using the contents of
in thread Using the contents of
UPDATE: IO::String and IO::Stringy both seem to be the sort of thing that you'd want here. The documentation suggests that they're only useful on older versions that don't support lexical filehandles, but it seems to me that lexical filehandles don't suffice for your situation.
UPDATE 2: ikegami pointed out what I was missing (i.e., why you shouldn't tie after all). Thanks!