script/mustache.pl untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 48 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/env perl
2 # Original: https://github.com/defunkt/mustache/blob/master/bin/mustache
3  
4 # PODNAME: mustache.pl
5  
6 use strict;
7 use warnings;
8 use autodie;
9  
10 use Template::Mustache;
11 use YAML::XS qw/ Load /;
12  
13 my ($self, $args) = @_;
14 my @args = $args ? @$args : @ARGV;
15 my $cli_opt = shift @args || '-h';
16  
17 if ($cli_opt eq "-h" and -t STDIN) {
18 print "Usage: mustache FILE ...\n";
19 print "`perldoc mustache` for more usage info.\n";
20 }
21 else {
22 my $doc = join('', <>);
23 if($doc =~ /^(\s*---(.+)---\s*)/isg) {
24 my $yml = $2;
25 $doc =~ s/\Q$1\E//g; # remove YAML data block, quote metachars
26 $yml =~ s/^\s+|\s+$//g; # trim whitespace
27 $yml = Load($yml);
28 print Template::Mustache->render($doc, $yml);
29 }
30 else {
31 print Template::Mustache->render($doc);
32 }
33 }
34  
35 __END__