home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / perl / scripts-convex / xfortune < prev    next >
Encoding:
Text File  |  1990-03-21  |  564 b   |  29 lines

  1. #!/usr/bin/perl
  2.  
  3. ($me = $0) =~ s,.*/,,;
  4.  
  5. $FORTUNE = '/usr/games/fortune';
  6. $TMP = "/tmp/$me.$$";
  7.  
  8. die "can't run $FORTUNE: $!" unless -x $FORTUNE;
  9.  
  10. open (FORTUNE, "$FORTUNE @ARGV | expand |");
  11. while (<FORTUNE>) {
  12.     $rows++;
  13.     $cols = length if $cols < length;
  14.     $fortune .= $_;
  15. (close FORTUNE) || die "bad pclose on $FORTUNE: $?";
  16.  
  17. $rows++, $cols++;
  18.  
  19. open (TMP, ">$TMP") || die "can't write $TMP: $!";
  20. print TMP $fortune;
  21. close TMP;
  22.  
  23. system 'xterm', '-geometry', "${cols}x${rows}", 
  24.     '-n', 'xfort', 
  25.     '-e', 'less', "-P(hit q to quit)", $TMP;
  26.  
  27. unlink $TMP;
  28.