File Coverage

blib/lib/Lingua/PigLatin.pm
Criterion Covered Total %
statement 14 16 87.5
branch 3 4 75.0
condition 0 3 0.0
subroutine 4 5 80.0
pod 0 2 0.0
total 21 30 70.0


line stmt bran cond sub pod time code
1             package Lingua::PigLatin;
2            
3 1     1   19627 use 5.008008;
  1         4  
  1         29  
4 1     1   5 use strict;
  1         2  
  1         27  
5 1     1   4 use warnings;
  1         5  
  1         387  
6            
7             require Exporter;
8            
9             our @ISA = qw(Exporter);
10            
11             # Items to export into callers namespace by default. Note: do not export
12             # names by default without a very good reason. Use EXPORT_OK instead.
13             # Do not simply export all your public functions/methods/constants.
14            
15             # This allows declaration use Lingua::PigLatin ':all';
16             # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
17             # will save memory.
18             our %EXPORT_TAGS = ( 'all' => [ qw(
19             piglatin
20             ) ] );
21            
22             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
23            
24             our @EXPORT = qw(
25            
26             );
27            
28             our $VERSION = '0.01';
29            
30            
31             # Preloaded methods go here.
32            
33             sub new {
34 0     0 0 0 my $class = shift;
35 0   0     0 bless {}, ref($class)||$class;
36             }
37            
38             sub piglatin {
39 1     1 0 9 local $_ = shift;
40 1 50       4 local $_ = shift if ref($_);
41            
42 1         9 s/\b(qu|[cgpstw]h # First syllable, including digraphs
43             |[^\W0-9_aeiou]) # Unless it begins with a vowel or number
44             ?([a-z]+)/ # Store the rest of the word in a variable
45 11 100       48 $1?"$2$1ay" # move the first syllable and add -ay
46             :"$2way" # unless it should get -way instead
47             /iegx;
48            
49 1         8 return $_;
50             }
51            
52            
53             1;
54             __END__