File Coverage

lib/Parse/File/Taxonomy/Auxiliary.pm
Criterion Covered Total %
statement 21 21 100.0
branch 4 4 100.0
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 30 32 93.7


line stmt bran cond sub pod time code
1             package Parse::File::Taxonomy::Auxiliary;
2 7     7   33 use strict;
  7         8  
  7         354  
3 7     7   33 use Carp;
  7         12  
  7         2278  
4             our ($VERSION, @ISA, @EXPORT_OK);
5             $VERSION = '0.04';
6             @ISA = qw( Exporter );
7             @EXPORT_OK = qw(
8             path_check_fields
9             components_check_fields
10             );
11              
12             =head1 NAME
13              
14             Parse::File::Taxonomy::Auxiliary - Utility subroutines for Parse::File::Taxonomy
15              
16             =head1 SYNOPSIS
17              
18             use Parse::File::Taxonomy::Auxiliary qw(
19             path_check_fields
20             components_check_fields
21             );
22              
23             =cut
24              
25             =head1 SUBROUTINES
26              
27             =cut
28              
29             sub path_check_fields {
30 28     28 0 37 my ($data, $fields_ref) = @_;
31 28         73 _check_fields($data, $fields_ref, 0);
32             }
33              
34             sub components_check_fields {
35 26     26 0 35 my ($data, $fields_ref) = @_;
36 26         58 _check_fields($data, $fields_ref, 1);
37             }
38              
39             sub _check_fields {
40 54     54   77 my ($data, $fields_ref, $components) = @_;
41 54         66 my %header_fields_seen;
42 54         60 for my $f (@{$fields_ref}) {
  54         106  
43 373 100       459 if (exists $header_fields_seen{$f}) {
44 4         6 my $error_msg = '';
45 4 100       15 if ($components) {
46 2         6 $error_msg = "Duplicate field '$f' observed in 'fields' array ref";
47             }
48             else {
49 2         8 $error_msg = "Duplicate field '$f' observed in '$data->{file}'";
50             }
51 4         799 croak $error_msg;
52             }
53             else {
54 369         633 $header_fields_seen{$f}++;
55             }
56             }
57             }
58              
59             1;
60              
61             # vim: formatoptions=crqot