Sure, here you go. In my defence, this was written 20 years ago ;-)

#!/usr/bin/perl use strict; use warnings; my ($ll, $numadd, @add); my @labpos = (2, 3, 6, 8, 7, 5, 4, 1); print "How many addresses? "; chomp ($numadd = <>); die 'Bad data' if ($numadd !~ /^[0-9]+$/); print "How many labels left? "; chomp ($ll = <>); die 'Bad data' if ($ll !~ /^[0-9]+$/); my $text = '\documentclass[10pt]{article} \usepackage{epsf} % was 23mm \setlength{\oddsidemargin}{-20.5mm} \setlength{\textwidth}{201.7mm} \setlength{\topmargin}{-24.5mm} \setlength{\textheight}{278mm} \setlength{\parindent}{0pt} \setlength{\parskip}{0pt} \pagestyle{empty} \begin{document} \setlength{\unitlength}{1mm} \begin{picture}(99.1,67.7) %%addlab1%% \end{picture}% \hspace{3.5mm}% \begin{picture}(99.1,67.7) %%addlab2%% \end{picture} \begin{picture}(99.1,67.7) %%addlab3%% \end{picture}% \hspace{3.5mm}% \begin{picture}(99.1,67.7) %%addlab4%% \end{picture} \begin{picture}(99.1,67.7) %%addlab5%% \end{picture}% \hspace{3.5mm}% \begin{picture}(99.1,67.7) %%addlab6%% \end{picture} \begin{picture}(99.1,67.7) %%addlab7%% \end{picture}% \hspace{3.5mm}% \begin{picture}(99.1,67.7) %%addlab8%% \end{picture} \end{document}'; my $this = ' \put(5,40){\parbox{80mm}{\Large \bf % was Large %%addr%% }} \epsfxsize=15mm \put(81,47){\epsfbox{logo.eps}} \put(3,7){\scriptsize \sf If undelivered, please return to:} \put(3,4){\scriptsize \sf Hippo Enterprises PLC, PO Box 999, Ungulatesville, XL99 9XL} '; for my $i (0 .. $numadd - 1) { $add[$i] = ''; print "Enter address $i (terminate with .)\n"; while ($_ = <>) { last if /^\./; $add[$i] .= $_; } $_ = $this; $_ =~ s/%%addr%%/$add[$i]/; $text =~ s/%\%addlab$labpos[8-$ll+$i]%%/$_/; } open OUT, '>address.tex' or die 'Cannot open outfile'; print OUT $text; close OUT; system ('make');

And the Makefile is just the standard

go: address.ps gv address.ps address.ps: address.dvi dvips -o address.ps address.dvi address.dvi: address.tex latex address.tex

When entering the addresses, they will need to include the \\ for LaTeX line breaks. Add your own code for this in the Perl if you want that handled by the script instead.

Why the Makefile? Well, occasionally something happens which the preview shows to be a problem. Most often you can simply manually edit address.tex and re-run the make command from the shell rather than re-processing the whole thing from scratch. YMMV.

In case it isn't clear, the "How many labels left?" prompt is referring to the number of unused labels remaining on the sheet of 8. Since you're also wondering what @labpos is all about, that's because if you just use up a few labels on a sheet in the normal order of left-to-right, top-to-bottom, the label sheets we use are thin enough once the labels have peeled off the backing that the printer starts having problems feeding them through. Thus my engineered fix is to use them up in a staggered/chequered pattern.

If anyone did want to turn this into a web-based system, it would be easy enough. But then there would really be no point to the Makefile.

Hope this is useful to somebody.


🦛


In reply to Re^3: Printing Labels by hippo
in thread Printing Labels by Bod

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.