File Coverage

lib/Perlmazing/Perlmazing/Precompile/remove_duplicates.pm
Criterion Covered Total %
statement 20 21 95.2
branch 9 12 75.0
condition 4 6 66.6
subroutine 2 2 100.0
pod n/a
total 35 41 85.3


line stmt bran cond sub pod time code
1 50     50   442 use Perlmazing;
  50         124  
  50         284  
2            
3             sub main (\@) {
4 2     2   1862 my $arr = shift;
5 2 50       7 $arr = [$arr, @_] unless isa_array $arr;
6 2         8 my @copy = @$arr;
7 2         4 my @duplicates;
8             my $seen;
9 2         4 my $undef = undef;
10 2         8 $undef = bless \$undef, 'undef';
11 2         9 for (my $i = 0; $i < @copy; $i++) {
12 66 100       123 $copy[$i] = $undef if not defined $copy[$i];
13 66 100       132 if ($seen->{$copy[$i]}) {
14 34         62 push @duplicates, splice @copy, $i, 1;
15 34         71 $i--;
16             } else {
17 32         80 $seen->{$copy[$i]} = 1;
18             }
19             }
20 2         5 for my $i (@copy) {
21 32 50 66     74 $i = undef if ref($i) and ref($i) eq 'undef' and $i eq $undef;
      66        
22             }
23 2 100       7 if (list_context()) {
    50          
24 1         10 return @copy;
25             } elsif (scalar_context()) {
26 0         0 return scalar @duplicates;
27             } else {
28 1         10 @$arr = @copy;
29             }
30             }
31