Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Thanks for the clarification. I should have read your original post more thoroughtly.

I tried all my tricks to fake out &Pod::Html::pod2html, but I can't make it work without resorting to pipes.

If you wish to resort to pipes, the following Worked For Me(tm).

use strict; use IO::File; use IO::Pipe; use Pod::Html qw( &pod2html ); # I only use $fh to get a pod string, It is not part # of the solution. my $fh = IO::File->new("<foo.pod") or die "filaed to open foo.pod: $!"; $fh->input_record_separator( undef ); my ($str); $str = $fh->getline(); $fh->close; # Got the pod string in $str my $pipe = IO::Pipe->new() or die "failed to create pipe: $!"; my ($pid,$fd); if ( $pid = fork() ) { #parent open(TMPSTDIN, "<&STDIN") or die "failed to dup stdin to tmp: $!"; $pipe->reader(); $fd = $pipe->fileno; open(STDIN, "<&=$fd") or die "failed to dup \$fd to STDIN: $!"; pod2html(); open(STDIN, "<&TMPSTDIN") or die "failed to restore dup'ed stdin: $!"; } else { #child $pipe->writer(); $pipe->print($str); $pipe->close(); exit 0; } $pipe->close(); exit 0;

I think this will work satifactorally even on the Win32 port of Perl. Win32 doesn't really fork(), it just creates a thread. But I restore the original STDIN and the child dies pretty quickly.


In reply to Re: Re: Re: Problem with tie *STDIN, 'IO::Scalar', \$text; by LunaticLeo
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-24 03:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found