| 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 |