#!/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"; }

In reply to Code Typesetter by Minimiscience

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.