#!/usr/bin/perl -w use strict; our $us = $0; $us =~ s#.*/##; our $papersize = 'creditcard'; our $count = 10; our $fontname = 'Courier'; our $usage = <] ... options: -p for libpaper, or "creditcard" default is $papersize -F font name default is $fontname END our @paperpts; sub badusage () { die "bad usage\n\n$usage"; } for (;;) { badusage unless @ARGV; last unless $ARGV[0] =~ m/^-/; $_ = shift @ARGV; last if m/^--?$/; while (m/^-./) { if (s/^-p(\w+)$//) { $papersize = $1; } elsif (s/^-n(\d{1,2})$//) { $count = 1; } elsif (s/^-F([^()\\]+)$//) { $fontname = $1; } else { badusage; } } } if ($papersize eq 'creditcard') { # ISO/IEC 7810 ID-1, from en.wikipedia.org/wiki/Payment_card @paperpts = map { $_ * 72.0 / 25.4 } qw(85.60 53.98); } else { $!=0; $?=0; my $r = `paperconf -sp $1`; defined $r or die "paperconf failed: $? $!\n"; $r =~ m/^([0-9.]+) ([0-9.]+)$/ or die "$_ ?"; @paperpts = ($1,$2); } @ARGV >= 2 or badusage; our @strings; our $nlen = 0; open P, "-|", @ARGV or die $!; while (

) { chomp or die; m/^(\d+) (\S+)$/ or die "$_ ?"; $nlen = length($1) if length($1) > $nlen; push @strings, [ $1, $2 ]; } $!=0; $?=0; close P or die "$us: generator failed: $! $?\n"; $_ = sprintf "%${nlen}s %s", @$_ foreach @strings; print $_,"\n" or die $! foreach @strings;