File Coverage

blib/lib/Petal/Utils/Equal.pm
Criterion Covered Total %
statement 27 28 96.4
branch 2 6 33.3
condition 4 12 33.3
subroutine 7 7 100.0
pod 0 1 0.0
total 40 54 74.0


line stmt bran cond sub pod time code
1             package Petal::Utils::Equal;
2              
3 4     4   20 use strict;
  4         7  
  4         124  
4 4     4   20 use warnings::register;
  4         6  
  4         406  
5              
6 4     4   53 use Carp;
  4         6  
  4         226  
7              
8 4     4   17 use base qw( Petal::Utils::Base );
  4         7  
  4         281  
9              
10 4     4   19 use constant name => 'equal';
  4         6  
  4         168  
11 4     4   18 use constant aliases => qw( eq );
  4         6  
  4         1038  
12              
13             our $VERSION = ((require Petal::Utils), $Petal::Utils::VERSION)[1];
14             our $REVISION = (split(/ /, ' $Revision: 1.3 $ '))[2];
15              
16             sub process {
17 1     1 0 88 my $class = shift;
18 1         2 my $hash = shift;
19 1   33     5 my $args = shift || confess( "'equal' expects 2 variables (got nothing)!" );
20              
21 1         9 my @args = $class->split_first_arg( $args );
22 1   33     4 my $arg1 = $args[0] || confess( "1st arg to 'equal' should be a variable (got nothing)!" );
23 1   33     19 my $arg2 = $args[1] || confess( "2nd arg to 'equal' should be a variable (got nothing)!" );
24              
25 1         5 my $h1 = $hash->fetch($arg1);
26 1         68 my $h2 = $hash->fetch($arg2);
27              
28 1 50 33     68 return $h1 == $h2 ? 1 : 0 if ($h1 =~ /\A\d+\z/ and $h2 =~ /\A\d+\z/);
    50          
29 0 0         return $h1 eq $h2 ? 1 : 0;
30             }
31              
32             1;