File: genfigs.pl

package info (click to toggle)
libpostscriptbarcode 20200401-1.1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 3,920 kB
  • sloc: ansic: 563; makefile: 304; perl: 277; xml: 243; sh: 107; lisp: 92; java: 73; python: 45; ruby: 21
file content (48 lines) | stat: -rwxr-xr-x 893 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/perl -w

use strict;

open(PS,'barcode.ps') || die 'File not found';
$_=join('',<PS>);
close(PS);
m/
    %\ --BEGIN\ TEMPLATE--
    (.*)
    %\ --END\ TEMPLATE--
    /sx || die 'Unable to parse out the template';
my $template='';
$template.="%!PS-Adobe-2.0 EPSF-2.0\n";
$template.="%%BoundingBox: 0 0 [% width %] [% height %]\n";
$template.="%%EndComments";
$template.=$1;
$template.="10 7 moveto\n";
$template.="[% call %]\n";
$template.="showpage\n";

open(IN,'figs.txt');
my @figs=<IN>;
close(IN);

foreach $_ (@figs) {
    m/^(.*):(.*):(.*):(.*)$/ || die "Bad line: $_";
    my $filename=$1;
    my $width=$2;
    my $height=$3;
    my $contents=$4;
    my $barcode=$template;
    $barcode=~s/\[% call %\]/$contents/;
    $barcode=~s/\[% width %\]/$width/;
    $barcode=~s/\[% height %\]/$height/;
    open(OUT,"> $filename");
    print OUT $barcode;
    close(OUT);
}