Path: utzoo!attcan!uunet!munnari.oz.au!uhccux!ames!mailrus!tut.cis.ohio-state.edu!purdue!haven!uvaarpa!mmdf From: martin%EASBY.DURHAM.AC.UK@CORNELLC.cit.cornell.edu (Martin Ward) Newsgroups: comp.lang.perl Subject: (none) Message-ID: <1990Jun1.205310.23678@uvaarpa.Virginia.EDU> Date: 1 Jun 90 20:53:10 GMT Sender: mmdf@uvaarpa.Virginia.EDU (Uvaarpa Mail System) Reply-To: martin%EASBY.DURHAM.AC.UK@CORNELLC.cit.cornell.edu Organization: The Internet Lines: 22 I have a small problem which I would like some perl wizards' help on (or perhaps it has already been solved). I would like to write a file "viewer", based on "less", which can cope with more than just ascii files in a sensible way. For example a compressed file should be piped through "uncompress" before viewing, a QED file should be passed through "qtoa", nroff files passed though nroff (with the appropriate macro package guessed at from the file?) etc. (other possibilities: use "tar -tf" on a tar file, "strings" on an executable and so on). A major requirement is that it should produce the first page of output quickly (ie using pipes rather than uncompressing etc. the whole file). So for example a compressed nroff file in QED editor form will be automatically passed to "uncompress | qtoa | nroff -man | less -s" Most of the file types can be gleaned from the magic no. or the first few lines of the file, which can then be re-read from the beginning and passed to the "pipe so far". But what if the input is from a pipe? It looks like we need some kind of "unread" or "putback" function. Ideas anyone? Martin. My ARPANET address is: martin%EASBY.DUR.AC.UK@CUNYVM.CUNY.EDU OR: martin%uk.ac.dur.easby@nfsnet-relay.ac.uk UUCP:...!mcvax!ukc!easby!martin JANET: martin@uk.ac.dur.easby BITNET: IN%"MARTIN@EASBY.DURHAM.AC.UK"