Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!zaphod.mps.ohio-state.edu!julius.cs.uiuc.edu!ux1.cso.uiuc.edu!phil From: phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) Newsgroups: comp.lang.perl Subject: Re: While learning PERL... a suggestion Keywords: perl file learn suggest Message-ID: <1991Jan21.091112.11546@ux1.cso.uiuc.edu> Date: 21 Jan 91 09:11:12 GMT References: <1991Jan19.003519.23569@ux1.cso.uiuc.edu> <11115@jpl-devvax.JPL.NASA.GOV> Organization: University of Illinois at Urbana Lines: 29 lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes: >There's no way to do this at all under Unix, let alone Perl, without >interposing a process to supply the magic number you destructively read >out of the pipe. You can't seek backwards on a pipe, and unless you can >convince compress to accept input without the leading magic number, you're >stuck. >As you pointed out, it wouldn't help to give Perl a -Z, since it would still >have to read the pipe. So I guess what one must do then is just read the file and look at the data and check for the magic number. Then if it looks compressed and you want to uncompress it, fork two more processes: 1. to write onto a socketpair prefixing the original data read and copy all the rest into process 2: 2. exec's compress writing out to yet another socketpair to 3: 3. performs the originally intended processing. Perhaps the order of forking can be done to keep #3 running in the same pid as originally, with #1 above inheriting the original STDIN or other file being read. I would just like to be able to do it without so many processes. -- --Phil Howard, KA9WGN-- | Individual CHOICE is fundamental to a free society | no matter what the particular issue is all about.