#!/usr/bin/perl -w
use strict;
foreach (@ARGV) {
open CODE, '<', $_ or die "Error opening $_: $!\n";
(my $ps = $_) =~ s/\.[^.]+$/.ps/;
open PS, '>', $ps or die "Error opening $ps: $!\n";
print PS <<EOT;
%!PS-Adobe-3.0
/Courier findfont 10 scalefont setfont
/pageNo 0 def /lineNo 0 def
/linefeed {y 84 le {showpage startPage} if /y y 12 sub def 1 eq {/line
+No lineNo 1 add def lineNo 5 mod 0 eq {61 y lineNo printNum} if} if 6
+6 y moveto} def
/hyphen {1 0 0 setrgbcolor (-) show 0 0 0 setrgbcolor 0 linefeed} def
/startPage {/pageNo pageNo 1 add def 66 725 moveto ($_) show 546 725 p
+ageNo printNum 66 722.5 moveto 480 0 rlineto stroke /y 722 def} def
/printNum {/str 20 string def str cvs stringwidth pop 3 2 roll sub neg
+ exch moveto str show} def
startPage
EOT
while (<CODE>) {
chomp;
1 while s/\t+/' ' x (length($&)*8 - length($`)%8)/e;
print PS "1 linefeed\n";
getline: my $line = substr $_, 0, length > 80 ? 79 : 80, '';
$line =~ s/([()\\])/\\$1/g;
print PS "($line) show ";
if ($_) {print PS "hyphen "; goto getline; }
}
print PS "showpage\n";
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|