script/figlet.pl untested

filter: Statementstmt 0.0% 0 / 74 Branchbran 0.0% 0 / 48 Conditioncond 0.0% 0 / 49 MC/DCmcdc 0.0% 0 / 25 Subroutinesub 0.0% 0 / 3 Podpod n/a totaltotal 0.0% 0 / 199 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/local/bin/perl -w
2 package main;
3 use strict;
4 use vars '$VERSION';
5 use Text::FIGlet 2.01;
6 $VERSION = 2.19.2;
7  
8 my %opts;
9 $opts{-C} = [];
10 $opts{$_} = undef for
11 qw(A D E L R U X c d e f h help -help l r x);
12 $opts{$_} = "0 but true" for
13 qw(I m w);
14 for (my $i=0; $i <= scalar @ARGV; $i++) {
15 last unless defined($ARGV[$i]);
16 shift && last if $ARGV[$i] eq '--';
17 if( $ARGV[$i] =~ /^-N$/ ) {
18 shift; $i--;
19 $opts{-C} = [];
20 }
21 if( $ARGV[$i] =~ /^-C=?(.*)/ ) {
22 shift; $i--;
23 $opts{-C} = [ @{$opts{-C}},
24 defined($1) && $1 ne '' ?
25 $1 : defined($opts{-C}) ? do{$i--; shift} : undef
26 ];
27 next;
28 }
29 foreach my $key ( sort { length($b)-length($a) } keys %opts) {
30 if( $ARGV[$i] =~ /^-$key=?(.*)/ ){
31 shift; $i--;
32 $opts{$key} = defined($1) && $1 ne '' ?
33 $1 : defined($opts{$key}) ? do{$i--; shift} : 1;
34 last;
35 }
36 }
37 }
38 defined($_) && $_ eq '0 but true' && ($_ = undef) for values %opts;
39 if( $opts{help}||$opts{h}||$opts{-help} ){
40 eval "use Pod::Text;";
41 die("Unable to print man page: $@\n") if $@;
42 pod2text(__FILE__);
43 exit 0;
44 }
45  
46 $opts{I} ||= 0;
47 if( $opts{I} == 1 ){
48 my @F = unpack("c*", $VERSION);
49 die(10_000 * $F[0] + 100 * $F[1] +$F[2], "\n");
50 }
51  
52 my $font = Text::FIGlet->new(-D=>$opts{D}&&!$opts{E},
53 -d=>$opts{d},
54 -m=>$opts{m}||-2,
55 -f=>$opts{f});
56 @_ = map { -C=> $_ } @{$opts{-C}} if scalar @{$opts{-C}};
57 my $ctrl = Text::FIGlet->new( @_,
58 -d=>$opts{d}) if @_;
59  
60 if( $opts{I} == 2 ){
61 die("$font->{-d}\n");
62 }
63 if( $opts{I} == 3 ){
64 die("$font->{-f}\n");
65 }
66  
67 my %figify = (
68 -U=>$opts{U},
69 -X=>($opts{L}&&'L')||($opts{R}&&'R'),
70 -m=>$opts{m},
71 -w=>$opts{w},
72 -x=>($opts{l}&&'l')||($opts{c}&&'c')||($opts{r}&&'r') );
73 croak("figlet.pl: cannot use both -A and -e") if $opts{A} && $opts{e};
74 if( $opts{e} ){
75 $opts{A} = 1;
76 @ARGV = eval "@ARGV";
77 croak($@) if $@;
78 }
79 if( $opts{A} ){
80 $_ = join(' ', map($_ = $_ eq '' ? $/ : $_, @ARGV));
81 #XXXtraneous space...
82 print scalar $font->figify(-A=>($ctrl ? $ctrl->tr() : $_), %figify);
83 exit 0;
84 }
85 else{
86 Text::FIGlet::croak("Usage: figlet.pl -help\n") if @ARGV;
87 print scalar $font->figify(-A=>($ctrl ? $ctrl->tr() : $_), %figify)
88 while <STDIN>;
89 }
90 __END__