home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / perl / 5610 < prev    next >
Encoding:
Internet Message Format  |  1992-08-30  |  2.2 KB

  1. 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
  2. From: joel@abigale.UUCP (Joel Rosi-Schwartz)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: more questions
  5. Message-ID: <1992Aug.105259.27539@abigale.uucp>
  6. Date: 29 Aug 92 09:52:59 GMT
  7. References: <1992Aug26.033044.9697@uoft02.utoledo.edu>
  8. Sender: Joel Rosi-Schwartz <joel@abigale.UUCP>
  9. Organization: Techne Research, Finchampstead, Berkshire (UK)
  10. Lines: 51
  11.  
  12. In article <1992Aug26.033044.9697@uoft02.utoledo.edu> steiner@jupiter.cse.utoledo.edu (jason "Think!" steiner) writes:
  13. >here's something i've been wondering about:
  14. >
  15. >what's the best way to pipe output through a pager? (in this case more)
  16. >i've tried just opening "|more", but that hangs on close, apparently
  17. >because more is waiting for its parent to finish, and perl is waiting
  18. >for more to exit. this also has the disadvantage that quitting more
  19. >half way through the output also quits perl.
  20. >
  21. >i've got a feeling this is very simple, but don't know what it is...
  22. >
  23.  
  24. I use code like this to page.
  25.  
  26. #### This is up top in my configuration section.
  27.  
  28. #
  29. # Take your pick of pagers, cat is a last resort!
  30. #
  31. $more = "/usr/local/bin/less";
  32. # $more = "/usr/bin/pg";
  33. # $more = "/usr/bin/more";
  34. # $more = "/usr/bin/cat";
  35.  
  36. #### I use code like this when I need the pager.
  37.  
  38. if ($i_need_to_page) {
  39.     die "Pager \"$more\" not found. Please seen CONFIG section of $0\n"
  40.         unless -x $more;
  41.  
  42.     open(MORE, "|$more");
  43.     $oldhandle = select(MORE);
  44.     $| = 1;
  45.     print "DO YOUR STUFF HERE";
  46.     close(MORE);
  47.     wait;
  48.     select($oldhandle);
  49. }
  50.  
  51. Cheers,
  52. Joel
  53. -- 
  54.      ==================================================================
  55.      ||               T E C H N E   R E S E A R C H                  ||
  56.      ||  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  ||
  57.      ||                     Joel Rosi-Schwartz                       ||
  58.      ||   Hildorien House            +   Email: joel@abigale.UUCP    ||
  59.      ||   12 Waverley Way            +    (pyrltd!abigale.UUCP!joel) ||
  60.      ||   Finchampstead, Wokingham   +   Phone: +44 (734) 730.260    ||
  61.      ||   Berkshire RG11 4YD (UK)    +   Fax:   +44 (734) 730.272    ||
  62.      ==================================================================
  63.