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

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.