blib/lib/Lingua/Klingon/Segment.pm

filter: Statementstmt 100% 28 / 28 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 100% 35 / 35 CC 2 SCAR 2.9
CC
2
Cov
100%
syllabify
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
↑ Summary
1 package Lingua::Klingon::Segment;
2 # vim:set tw=72 sw=2:
3  
4 3 ▶use 5.005;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 require Exporter;
8 3 ▶use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $keep_accents);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 @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::Klingon::Segment ':all';
16 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
17 # will save memory.
18 3 %EXPORT_TAGS = ( 'all' => [ qw(
19 syllabify
20 spell
21 ) ] );
22  
23 3 @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
24  
25 3 @EXPORT = qw(
26
27 );
28 3 $VERSION = '1.03';
29  
30 3 my $letter = qr/tlh|ch|gh|ng(?!h)|[abDeHIjlmnopqQrStuvwy']/;
31 3 my $consonant = qr/tlh|ch|gh|ng(?!h)|[bDHjlmnpqQrStvwy']/;
32 3 my $vowel = qr/[aeIou]/;
33 3 my $head = $consonant;
34 3 my $tail = qr/rgh|w'|y'|$consonant/o;
35  
36  
37 30 ▶sub syllabify {
Subroutine syllabify: called CC=2 SCAR=6.9
Pod documented
38 30 my @syllables;
39 30 foreach my $word ($_[0] =~ /($letter+)/go) {
40 36 push @syllables, $word =~ /\G($head$vowel$tail?)(?=(?:$head$vowel$tail?)*$)/goc;
41 }
42 30 @syllables;
43 }
44  
45  
46 30 ▶sub spell {
Subroutine spell: called CC=1 SCAR=0.0
Pod documented
47 30 my @letters;
48 30 @letters = $_[0] =~ /($letter)/go;
49 30 @letters;
50 }
51  
52  
53 3 1;
54 __END__
↑ Summary