File Coverage

blib/lib/Silly/Werder/English.pm
Criterion Covered Total %
statement 28 29 96.5
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 35 38 92.1


line stmt bran cond sub pod time code
1              
2             package Silly::Werder::English;
3              
4             $Silly::Werder::English::VERSION='0.90';
5              
6 1     1   5 use strict;
  1         2  
  1         42  
7 1     1   5 use Exporter;
  1         2  
  1         45  
8 1     1   6 use Storable;
  1         1  
  1         59  
9 1     1   6 use File::Spec::Functions;
  1         2  
  1         96  
10              
11 1         346 use vars qw($VERSION $PACKAGE
12             @ISA
13 1     1   11 @EXPORT @EXPORT_OK);
  1         2  
14              
15             @ISA = 'Exporter';
16              
17             my @export_functions = qw(LoadGrammar
18             );
19              
20             @EXPORT_OK = (@export_functions);
21              
22             sub LoadGrammar {
23 1     1 0 2 my $which = shift;
24 1         2 my ($locate_ref, $grammar_ref);
25              
26             # Prepend the variant with a - if it exists
27 1 50       3 if($which) { $which = "-" . $which; }
  0         0  
28 1         2 else { $which = ""; }
29              
30 1         5 (my $dir = $INC{'Silly/Werder.pm'}) =~ s/\.pm//;
31 1         10 $dir = catdir($dir, 'data');
32 1         6 my $grammar_file = catfile($dir, 'english' . $which);
33              
34 1         5 $grammar_ref = retrieve($grammar_file);
35              
36 1         43096 my $count = scalar(@{$grammar_ref});
  1         3  
37              
38 1         10 for(my $i = 0; $i < $count; $i++) {
39 1766         7159 $locate_ref->{$grammar_ref->[$i][0]} = $i;
40             }
41 1         8 return($grammar_ref, $locate_ref);
42             }
43              
44             1;
45              
46             __END__