|We don't bite newbies here... much|
Streaming to Handlesby crabbdean (Pilgrim)
|on May 01, 2004 at 07:40 UTC||Need Help??|
crabbdean has asked for the
wisdom of the Perl Monks concerning the following question:
I'm writing code that attempts to output data to a filehandle, either STDOUT or whatever is specified. I want it to stream the output so that in your calling script you can work with each line of output as it comes out. The below code gives the guts of everything (more a watered-down version so you get an idea of my problem.)
My problem is that my module that does all the work prints the output to the specified HANDLE, but you can't work with the output. eg. If you output to LOGFILE in my calling the normal structure of ...
... doesn't work. The reason being is that my module outputs straight to the output file handle insteading of returing it to my main calling script.
In the example given you can see the section I've marked as "##problem??" doesn't output each entry with a newline character. The output is being directly spat out from the module.
How do I capture the output as an input stream to my calling program? What am I doing wrong? Is this making sense? (see code in the readmore section)
My calling program is this:
The module is this:
The Funkster of Mirth
Programming these days takes more than a lone avenger with a compiler. - sam
RFC1149: A Standard for the Transmission of IP Datagrams on Avian Carriers