http://qs321.pair.com?node_id=76473


in reply to Re: Problem with tie *STDIN, 'IO::Scalar', \$text;
in thread Problem with tie *STDIN, 'IO::Scalar', \$text;

Hi chromatic

At some other time I will probably follow your advice and learn how to subclass Tie::Handle to solve some specific problem.

At this stage I am raising what to me looks like a general perl programming question:

Some popular perl modules export subroutines that read text from specified input file(s), defaulting to STDIN, transform the text, and deliver the result to a specified output file, defaulting to STDOUT. This is fine in many applications.

Two subroutines that behave like this, and that I'm interested in right now are
Pod::Html::pod2html Pod::Select::podselect

However, I want to call these subroutines in a context where the input text or output text, or both, are in my script's scalar variables. This lets me do some other processing before calling one of these subroutines, and some more after the call.

I would like to know if other monks have had this of requirement or wish.

While I can easily solve my problems by using temporary files, out of curiosity I started looking for a more perlish solution. Following stephen's advice, I was able to redirect podselect STDOUT into a IO::Scalar tied to a scalar variable (see the first snippet in my post above). However, my attempt to use a similar redirection on STDIN to pod2html failed. I will try to dig deeper to try to understand why does it work when it works, and why not when not.

Rudif