home *** CD-ROM | disk | FTP | other *** search
- Path: tut.cis.ohio-state.edu!cs.utexas.edu!milano!lad-shrike!ut-emx!think
- From: think@ut-emx.UUCP (s j moon)
- Newsgroups: alt.sources
- Subject: rdabst.pl -- read info-mac abstract file
- Keywords: perl mac info-mac abstract read
- Message-ID: <20436@ut-emx.UUCP>
- Date: 3 Nov 89 19:39:23 GMT
- Organization: The University of Texas at Austin, Austin, Texas
- Lines: 130
- Posted: Fri Nov 3 13:39:23 1989
-
-
-
- Here is another small perl program.
- It is useful if you access info-mac macintosh archieve.
-
- This can display the title/content of abstract file.
- ex: 00da-abstracts.abs
- Sometimes the absract file is too long so I coded this program.
- It displays title of each .hqx file or its content from abstract.
-
- 1: #### BINHEX abc-calculator.hqx ************
- 2: #### BINHEX about-finder.hqx **************
- 3: #### BINHEX aclock2.hqx *******************
- 4: #### BINHEX amortization.hqx **************
-
- You can select any title by number and display its content.
- type 'h' for help
-
- q Quit.
- c N Change default no. of lines(20)
- m Change mode titles/contents(toggle)
-
- <cr> List 20 lines from current pointer.
- N change title pointer to title line N.
-
-
- s j moon <think@emx.utexas.edu>
-
- ---------- cut here --------------
- #!/usr/uns/perl
- # It is not in /bin of my emx computer
-
- #
- # Name: rdabst.pl
- # by Sungjin Moon think@emx.utexas.edu
-
- # format: perl rdabst file
- # or rdabst file if edbh is executable
- # description: read info-mac abstract
-
- $abstfile = shift;
- die "Usage: rd file" unless $abstfile;
- open(abstfile, "$abstfile") || die "Can't open $abstfile";
-
- $mode = 1; # title mode
- $cp = 1; # current pointer to content buffer
- $tcp = 1; # current pointer to title buffer
- $len = 20; # default length of display lines
-
- $first = 1; # pointer to first text
- $last = 0; # pointer to last text
- $tlast= 0; # pointer to last title
-
- # read in the file
-
- while (<abstfile>) {
- if(($buf[++$last] = $_) =~ /^\#\#\#\#/) {
- $tbuf[++$tlast]=$buf[$last]; # header
- $nbuf[$tlast]=$last; # line number of the header
- }
- }
-
- close abstfile;
- print "$last Lines Read In.\n";
- print "Type h for help.\n";
- do ED();
-
- #
- #
- sub ED {
- for (;;) {
- print " rd -- ";
- $cmd = <stdin>;
-
- if ($cmd =~ /^q$/) {
- exit 0;
- }
-
- if ($cmd =~ /^h$/) {
- print "
- q Quit.
- c N Change default no. of lines(20)
- m Change mode titles/contents(toggle)
-
- <cr> List 20 lines from current pointer.
- N change title pointer to title line N.
-
- ";
- next;
- }
- if ($cmd =~ /^c (.*)/) {
- $len = $1;
- next;
- }
- if ($cmd =~ /^([0-9]+)$/) {
- $tcp = $1;
- $cp = $nbuf[$tcp];
- $mode = 1;
- next;
- }
- if ($cmd =~ /^m/) {
- $mode = ! $mode;
- next;
- }
- if ($cmd =~ /^$/) {
- if($mode) { # diplay title
- $k = ($tlast-$tcp)<$len ? ($tlast-$tcp) : $len;
- for($i=$tcp;$i < $tcp+$k;$i++) {
- print "$i:\t", $tbuf[$i];
- }
- $tcp += $k - 1;
- $cp = $nbuf[$tcp];
- }
- else { # display content
- $k = ($last-$cp)<$len ? ($last-$tcp) : $len;
- for($i=$cp;$i < $cp+$k;$i++) {
- print " ", $buf[$i];
- if($buf[$i] =~ /^\#\#\#\#/) { $tmp = $i; }
- }
- # change current title pointer
- for($i=1;$i < $tlast;$i++) {
- if($nbuf[$i] == $tmp) { $tcp = $i; }
- }
- $cp += $k - 1;
- }
- next;
- }
- print "Syntax error: type h for help.\n";
- } # end of for
- } # end of sub ED
-