File Coverage

blib/lib/Petal/Utils/Printf.pm
Criterion Covered Total %
statement 28 28 100.0
branch n/a
condition 1 3 33.3
subroutine 7 7 100.0
pod 0 1 0.0
total 36 39 92.3


line stmt bran cond sub pod time code
1             package Petal::Utils::Printf;
2              
3 5     5   31 use strict;
  5         10  
  5         166  
4 5     5   30 use warnings::register;
  5         8  
  5         609  
5              
6 5     5   26 use Carp;
  5         10  
  5         354  
7              
8 5     5   28 use base qw( Petal::Utils::Base );
  5         10  
  5         437  
9              
10 5     5   31 use constant name => 'printf';
  5         10  
  5         425  
11 5     5   28 use constant aliases => qw();
  5         10  
  5         1273  
12              
13             our $VERSION = ((require Petal::Utils), $Petal::Utils::VERSION)[1];
14             our $REVISION = (split(/ /, ' $Revision: 1.3 $ '))[2];
15              
16             sub process {
17 6     6 0 23608 my $class = shift;
18 6         10 my $hash = shift;
19 6   33     18 my $args = shift || confess( "'printf' expects at least 2 arguments (got nothing)!" );
20              
21 6         28 my @tokens = $class->split_args( $args );
22 6         12 my $format = shift @tokens;
23 6         21 $format =~ s/\'//g;
24 6         11 my @printf_args = ();
25 6         10 foreach my $arg (@tokens) {
26 7         106 push @printf_args, $class->fetch_arg($hash, $arg);
27             }
28 6         549 return sprintf($format, @printf_args);
29             }
30              
31              
32              
33             1;
34              
35             __END__