home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!brunix!brunix!jgm
- From: jgm@cs.brown.edu (Jonathan Monsarrat)
- Subject: Re: perl and Post Script
- Message-ID: <1992Nov23.130915.19496@cs.brown.edu>
- Sender: news@cs.brown.edu
- Organization: Brown University Department of Computer Science
- References: <1992Nov22.163612.15510@r-node.gts.org>
- Date: Mon, 23 Nov 1992 13:09:15 GMT
- Lines: 45
-
- > Could someone suggest a script which converts Post Script files into
- > simple ASCII format, stripping the formatting characters and the
- > brackets?
-
- Doubtless some Perl God can write this with one line of /%$\/#Q$%#3'!/.
- Here's it is with 23! :)
-
- Let me know if you want a PS->ASCII converter that retains positional
- information. I have one written in PostScript. In general, because
- ASCII "A" does not always print "A" on the printer (in some weirdo
- fonts like Symbol), translating to ASCII from strings perfectly is not
- possible. Some programs like TeX deliberately replace the double-quote
- character with a non-ASCII font encoding, etc, etc.
-
- Handling the string (foo\)) properly is left as an exercise to the reader.
-
- -Jon
- %! Jon Monsarrat jgm@cs.brown.edu Brown University %! Obfuscated PostScript
- 0 0 moveto 15 setlinewidth(qlllll-??LHHL??llH?hH7t,7olCAHH@)1 setlinejoin{dup
- 10 mul rotate 80 lt{50 0 rlineto}{50 0 rmoveto}ifelse}forall stroke showpage
-
- ------------------------------ cut here ----------------------------
- #! /usr/local/bin/perl -P
- ########################################################
- # ps2ascii: look through a PostScript file for ASCII strings
- #
- # Usage:
- # ps2ascii <inputfile.ps>
- #
- ########################################################
-
- $out = "";
- while(<>)
- {
- $line = $_;
- while($line =~/\((.*)\)(.*)/) {
- $line = $2;
- if(length($out)+length($1) > 76) {
- print "$out\n";
- $out="";
- }
- $out=$out." ".$1;
- }
- }
- print "$out\n";
-