File Coverage

blib/lib/App/ForKids/LogicalPuzzleGenerator/Variable/Name.pm
Criterion Covered Total %
statement 12 24 50.0
branch 0 2 0.0
condition n/a
subroutine 4 5 80.0
pod 1 1 100.0
total 17 32 53.1


line stmt bran cond sub pod time code
1             package App::ForKids::LogicalPuzzleGenerator::Variable::Name;
2              
3 1     1   6 use strict;
  1         2  
  1         23  
4 1     1   4 use warnings FATAL => 'all';
  1         2  
  1         23  
5 1     1   4 use Carp;
  1         1  
  1         41  
6 1     1   4 use base 'App::ForKids::LogicalPuzzleGenerator::Variable';
  1         2  
  1         358  
7              
8              
9             =head1 NAME
10              
11             App::ForKids::LogicalPuzzleGenerator::Variable::Name
12              
13             =head1 VERSION
14              
15             Version 0.01
16              
17             =cut
18              
19             our $VERSION = '0.01';
20              
21              
22             =head1 SYNOPSIS
23              
24             The module is used by the App::ForKids::LogicalPuzzleGenerator.
25              
26             use App::ForKids::LogicalPuzzleGenerator;
27              
28             =cut
29              
30             our @names =
31             (
32             "Patrick",
33             "Stephen",
34             "Leonard",
35             "William",
36             "James",
37             "John"
38             );
39              
40             =head1 SUBROUTINES/METHODS
41              
42             =head2 new
43              
44             =cut
45              
46             sub new
47             {
48 0     0 1   my $class = shift;
49 0           my $this = $class->SUPER::new(@_);
50              
51             # select the names
52 0           for my $i (0..$$this{amount_of_values}-1)
53             {
54 0           while (1)
55             {
56 0           my $value = $names[int(rand()*@names)];
57 0 0         if (!grep {$_ eq $value } @{$$this{selected_values}})
  0            
  0            
58             {
59 0           push @{$$this{selected_values}}, $value;
  0            
60 0           last;
61             }
62             }
63             }
64 0           return $this;
65             }
66              
67              
68             =head1 AUTHOR
69              
70             Pawel Biernacki, C<< >>
71              
72             =head1 BUGS
73              
74             Please report any bugs or feature requests to C, or through
75             the web interface at L. I will be notified, and then you'll
76             automatically be notified of progress on your bug as I make changes.
77              
78              
79             =cut
80              
81             1;