File Coverage

blib/lib/Acme/Phlegethoth.pm
Criterion Covered Total %
statement 28 42 66.6
branch 2 22 9.0
condition 2 11 18.1
subroutine 8 10 80.0
pod 2 5 40.0
total 42 90 46.6


line stmt bran cond sub pod time code
1             package Acme::Phlegethoth;
2              
3 1     1   504 use warnings;
  1         2  
  1         31  
4 1     1   4 use strict;
  1         2  
  1         517  
5              
6             our $VERSION = '1.05';
7             my $hear_me = "ia ia! ";
8             my $amen = " [Text ends abruptly.]\n";
9             my @pre = qw( c f' h' na nafl ng nnn ph' y );
10             my @suf = qw( agl nyth og or oth yar );
11             my @word = qw(
12             ah 'ai athg 'bthnk bug ch' chtenff ebumna ee ehye ep 'fhalma fhtagn
13             fm'latgh ftaghu geb gnaiih gof'nn goka gotha grah'n hafh'drn hai
14             hlirgh hrii hupadgh ilyaa k'yarnak kadishtu kn'a li'hee llll lloig
15             lw'nafh mg mnahn' n'gha n'ghft nglui nilgh'ri nog nw ooboshu orr'e
16             phlegeth r'luh ron s'uhn sgn'wahl shagg shogg shtunggli shugg sll'ha
17             stell'bsna syha'n tharanak throd uaaah uh'e uln vulgtlagln vulgtm
18             wgah'n y'hah ya zhro
19             );
20              
21             sub summon {
22 0     0 1 0 my $old_one = unpack "b*", shift;
23 0         0 my $prayer = $hear_me;
24 0         0 my $chant = "";
25              
26 0         0 foreach my $tentacle (split //, $old_one) {
27 0 0       0 $chant = reverse(
    0          
    0          
    0          
28             ((rand() < 0.25) ? $pre[rand @pre] : "") .
29             $word[rand @word] .
30             ((rand() < 0.25) ? $suf[rand @suf] : "") .
31             ((rand() < 0.1) ? "! " : "") .
32             " "
33             ) unless length $chant;
34 0 0       0 $prayer .= $1, redo if $chant =~ s/([^a-z])$//;
35 0         0 $prayer .= chop $chant;
36 0 0       0 substr($prayer, -1, 1) =~ tr[a-z][A-Z] if $tentacle;
37             }
38              
39 0         0 $prayer .= $amen;
40             }
41              
42             sub banish {
43 1     1 1 2 local $_ = shift;
44 1         8 s/^\Q$hear_me//; s/\Q$amen\E$//; tr[a-zA-Z][]cd; tr[a-z][0]; tr[A-Z][1];
  1         11  
  1         6  
  1         5  
  1         3  
45 1         75 pack "b*", $_;
46             }
47              
48 1     1 0 6 sub see { $_[0] =~ /\S/ }
49 1     1 0 14 sub comprehend { $_[0] =~ /^\Q$hear_me/ }
50 0     0 0 0 sub roll_sanity_check { &see }
51              
52             sub import {
53 1     1   5 no strict 'refs';
  1         5  
  1         247  
54 1 50 0 1   38 open 0 or warn "Can't summon '$0'\n" and exit;
55 1         48 (my $old1 = join "", <0>) =~ (
56             s/(.*^\s*)use\s+Acme('|::)Phlegethoth\s*;\s*\n//sm
57             );
58 1   50     8 my $harbinger = $1 || "";
59 1         5 local $SIG{__WARN__} = \&roll_sanity_check;
60 1 50 33 1   977 do {eval banish $old1; exit} unless see $old1 and not comprehend $old1;
  1         18243  
  1         10  
  1         3  
  1         2  
  1         3937  
61 0 0 0       open 0, ">$0" or warn "Can't banish '$0'\n" and exit;
62 0 0         print {0} "${harbinger}use Acme'Phlegethoth;\n", summon $old1 and exit;
  0            
63 0 0         print "${harbinger}use Acme'Phlegethoth;\n", summon $old1 and exit;
64             }
65              
66             __END__