File Coverage

blib/lib/Petal/Utils/Decode.pm
Criterion Covered Total %
statement 31 31 100.0
branch 4 4 100.0
condition 1 3 33.3
subroutine 8 8 100.0
pod 0 1 0.0
total 44 47 93.6


line stmt bran cond sub pod time code
1             package Petal::Utils::Decode;
2              
3 4     4   22 use strict;
  4         8  
  4         143  
4 4     4   21 use warnings::register;
  4         6  
  4         542  
5              
6 4     4   23 use Carp;
  4         11  
  4         260  
7              
8 4     4   19 use base qw( Petal::Utils::Base );
  4         6  
  4         339  
9              
10 4     4   21 use constant name => 'decode';
  4         8  
  4         214  
11 4     4   21 use constant aliases => qw();
  4         9  
  4         691  
12              
13             our $VERSION = ((require Petal::Utils), $Petal::Utils::VERSION)[1];
14             our $REVISION = (split(/ /, ' $Revision: 1.3 $ '))[2];
15              
16             sub process {
17 16     16 0 44688 my $class = shift;
18 16         22 my $hash = shift;
19 16   33     35 my $args = shift || confess( "'decode' expects at least 1 variable (got nothing)!" );
20              
21 16         60 my @tokens = $class->split_args( $args );
22              
23 16         59 my $tvar = $class->fetch_arg($hash, shift @tokens);
24 4     4   1887 use Data::Dumper;
  4         8705  
  4         583  
25 16         1091 while(@tokens) {
26 21         70 my $a = $class->fetch_arg($hash, shift @tokens);
27 21         285 my $b = $class->fetch_arg($hash, shift @tokens);
28 21 100       118 return $a unless defined($b);
29 15 100       159 return $b if ($tvar =~ /$a/);
30             }
31             }
32              
33              
34              
35             1;
36              
37             __END__