home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pmafire!news.dell.com!swrinde!cs.utexas.edu!hermes.chpc.utexas.edu!news.utdallas.edu!convex!tchrist
- From: tchrist@convex.COM (Tom Christiansen)
- Newsgroups: comp.lang.perl
- Subject: Re: write
- Message-ID: <1992Jul24.161333.23225@news.eng.convex.com>
- Date: 24 Jul 92 16:13:33 GMT
- References: <1992Jul23.155101.22025@noose.ecn.purdue.edu>
- Sender: usenet@news.eng.convex.com (news access account)
- Reply-To: tchrist@convex.COM (Tom Christiansen)
- Organization: CONVEX Realtime Development, Colorado Springs, CO
- Lines: 27
- Originator: tchrist@pixel.convex.com
- Nntp-Posting-Host: pixel.convex.com
- X-Disclaimer: This message was written by a user at CONVEX Computer
- Corp. The opinions expressed are those of the user and
- not necessarily those of CONVEX.
-
- From the keyboard of newlin@purcell.ecn.purdue.edu (Johnny N.):
- :Is there any way to make write send its output to a buffer instead
- :of a filehandle? The only way that I could figure out to do this
- :is to send the output to a temporary file and then read it back in.
- :Needless to say, this is less than efficient.
-
- The workaround way is to fork a child of yourself with open to "|-"
- to do that kind of thing for you
-
- die "can't fork: $!" unless defined ($pid = open(KID, "|-"));
- if ($pid) {
- select(KID);
- # now write() to KID
- } else {
- while (<STDIN>) {
- # now do what you want
- }
- exit;
- }
-
-
- --tom
- --
- Tom Christiansen tchrist@convex.com convex!tchrist
-
-
- It's all magic. :-) --Larry Wall in <7282@jpl-devvax.JPL.NASA.GOV>
-