home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!news!netlabs!lwall
- From: lwall@netlabs.com (Larry Wall)
- Newsgroups: comp.lang.perl
- Subject: Re: reopening STDOUT as another stream
- Message-ID: <1992Sep6.040444.25185@netlabs.com>
- Date: 6 Sep 92 04:04:44 GMT
- References: <1992Sep5.071243.8404@netlabs.com> <lahv06INN169@jethro.Corp.Sun.COM>
- Sender: news@netlabs.com
- Organization: NetLabs, Inc.
- Lines: 21
- Nntp-Posting-Host: scalpel.netlabs.com
-
- In article <lahv06INN169@jethro.Corp.Sun.COM> tmhoff@oogoody.Corp.Sun.COM writes:
- : >If you aren't running an ancient version, ordinary open should work
- : >fine for that: open(STDOUT, "| lpr")
- :
- : Not quite what I was looking for. I have DEBUG and LOG output streams.
- : Sometimes I want DEBUG and LOG to goto STDOUT, sometimes I want them to
- : goto different streams. In C use freopen.
-
- Sounds more like you want a dupish thingy then. You can use >&FILEHANLE
- to do that. Suppose you set up environment variables to say where
- to put DEBUG and LOG.
-
- open(DEBUG, $ENV{DEBUG} ? ">$ENV{DEBUG}" : ">&STDOUT");
- open(LOG, $ENV{LOG} ? ">$ENV{LOG}" : ">&STDOUT");
-
- or, written sideways,
-
- open(DEBUG, ">" . ($ENV{DEBUG} || "&STDOUT"));
- open(LOG, ">" . ($ENV{LOG} || "&STDOUT"));
-
- Larry
-