tt.pl untested

filter: Statementstmt 0.0% 0 / 25 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 45 CC 2 SCAR 12.8
CC
2
Cov
0%
pod_code
6.0
pod_include
2.0
BEGIN
2.0
CRAP 3.6
1 #!/usr/bin/perl
2  
3 use Text::Template;
4 use strict;
5 our $OUT;
6  
7 my $file = shift or die 'file name not supplied';
8 my $out = "${file}-out";
9  
10 my $template = Text::Template->new
11 (TYPE => 'FILE', SOURCE => $file, DELIMITERS => [ '<tt>', '</tt>' ]);
12
13 sub pod_include {
14 my ($file, $indent, $prepend) = @_;
15  
16 open F, $file or die "couldnt open file : $!";
17
18 $OUT = $prepend;
19  
20 my $spaces = " " x $indent;
21  
22 while (<F>) {
23 $OUT .= "$spaces$_";
24 }
25 $OUT;
26 }
27  
28 sub pod_code {
29
30 my $file = shift or die "NO FILE SUPPLIED";
31 my $show_filename = shift;
32 my $flag = " #\n # $file\n #\n \n" if $show_filename;
33 pod_include($file, 1, $flag);
34  
35 }
36  
37 open O, ">$out" or die "couldnt open $out: $!";
38  
39 print O $template->fill_in;
40  
41 close(O);
42