home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ferkel.ucsb.edu!ucsbcsl!network.ucsd.edu!swrinde!gatech!bloom-beacon!eru.mt.luth.se!lunic!sunic!mcsun!uknet!pyrltd!abigale!joel
- From: joel@abigale.UUCP (Joel Rosi-Schwartz)
- Newsgroups: comp.lang.perl
- Subject: Re: more questions
- Message-ID: <1992Aug.105259.27539@abigale.uucp>
- Date: 29 Aug 92 09:52:59 GMT
- References: <1992Aug26.033044.9697@uoft02.utoledo.edu>
- Sender: Joel Rosi-Schwartz <joel@abigale.UUCP>
- Organization: Techne Research, Finchampstead, Berkshire (UK)
- Lines: 51
-
- In article <1992Aug26.033044.9697@uoft02.utoledo.edu> steiner@jupiter.cse.utoledo.edu (jason "Think!" steiner) writes:
- >here's something i've been wondering about:
- >
- >what's the best way to pipe output through a pager? (in this case more)
- >i've tried just opening "|more", but that hangs on close, apparently
- >because more is waiting for its parent to finish, and perl is waiting
- >for more to exit. this also has the disadvantage that quitting more
- >half way through the output also quits perl.
- >
- >i've got a feeling this is very simple, but don't know what it is...
- >
-
- I use code like this to page.
-
- #### This is up top in my configuration section.
-
- #
- # Take your pick of pagers, cat is a last resort!
- #
- $more = "/usr/local/bin/less";
- # $more = "/usr/bin/pg";
- # $more = "/usr/bin/more";
- # $more = "/usr/bin/cat";
-
- #### I use code like this when I need the pager.
-
- if ($i_need_to_page) {
- die "Pager \"$more\" not found. Please seen CONFIG section of $0\n"
- unless -x $more;
-
- open(MORE, "|$more");
- $oldhandle = select(MORE);
- $| = 1;
- print "DO YOUR STUFF HERE";
- close(MORE);
- wait;
- select($oldhandle);
- }
-
- Cheers,
- Joel
- --
- ==================================================================
- || T E C H N E R E S E A R C H ||
- || ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ||
- || Joel Rosi-Schwartz ||
- || Hildorien House + Email: joel@abigale.UUCP ||
- || 12 Waverley Way + (pyrltd!abigale.UUCP!joel) ||
- || Finchampstead, Wokingham + Phone: +44 (734) 730.260 ||
- || Berkshire RG11 4YD (UK) + Fax: +44 (734) 730.272 ||
- ==================================================================
-