blib/lib/Acme/DeepThoughts.pm

filter: Statementstmt 60.0% 6 / 10 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 0.0% 0 / 4 totaltotal 50.0% 9 / 18 CC 1 SCAR 2.2
CC
1
Cov
60%
deflect
2.0
reflect
1.0
opaque
1.0
CRAP 1.2
↑ Summary
1 package Acme::DeepThoughts;
2 $VERSION = '0.01';
3
4 my $glass = " \t"x8;
5 1 ▶sub reflect { local $_ = unpack "b*", pop; tr/01/ \t/; s/(.{9})/$1\n/g; $glass.$_ }
Subroutine reflect: called CC=1 SCAR=0.0
Pod undocumented
6 0 ▶sub deflect { local $_ = pop; s/^$glass|[^ \t]//g; tr/ \t/01/; pack "b*", $_ }
Subroutine deflect: not called CC=1 SCAR=6.9
Pod undocumented
7 1 ▶sub opaque { $_[0] =~ /\S/ }
Subroutine opaque: called CC=1 SCAR=0.0
Pod undocumented
8 1 ▶sub deep { $_[0] =~ /^$glass/ }
Subroutine deep: called CC=1 SCAR=0.0
Pod undocumented
9
10 open 0 or print "Can't open '$0'\n" and exit;
11 (my $thought = join "", <0>) =~ s/.*^\s*use\s+Acme::DeepThoughts\s*;\n\n(?:.*?--\s+Jack\s+Handey.*?\n)?//sm;
12
13 local $SIG{__WARN__} = \&opaque;
14 do {eval deflect $thought; exit} unless opaque $thought and not deep $thought;
15
16 my $DeepThought = '';
17 {
18 my $rand = int rand 152;
19 while($rand > 0){
20 $DeepThought = <DATA>;
21 $rand--;
22 }
23 close DATA;
24 chomp $DeepThought;
25
26 require Text::Wrap;
27 local $Text::Wrap::columns = 72;
28
29 my @lines = Text::Wrap::wrap('', '', $DeepThought);
30
31 if(length $lines[-1] < 63 ){
32 $lines[-1] .= " -- Jack Handey";
33 } else {
34 push @lines, " -- Jack Handey";
35 }
36
37 $DeepThought = join "\n",@lines;
38 }
39
40 open 0, ">$0" or print "Cannot ponder '$0'\n" and exit;
41 print {0} "use Acme::DeepThoughts;\n\n$DeepThought\n", reflect $thought and exit;
42
43 =head1 NAME
44
45 Acme::DeepThoughts - Jack Handey does perl
46
47
48 =head1 SYNOPSIS
49
50 use Acme::DeepThoughts
51 print "Hello world";
52
53 =head1 DESCRIPTION
54
55 The first time you run a program under C<use Acme::DeepThoughts>, the module
56 removes all the unsightly printable characters from
57 your source file. The code continues to work exactly as it did before,
58 but now it contains a I<Deep Thought>.
59
60 These deep thoughts were collected from E<lt>L<http://deepthoughts.330.ca/>E<gt>,
61 which is a site "I<dedicated to the quotes that used to appear on the hit TV show, Saturday Night Live (SNL)>."
62
63 =head1 BUGS
64
65 Please don't report bugs ;)
66 But if you really really need to, go to
67 E<lt>http://rt.cpan.org/NoAuth/Bugs.html?Dist=Acme-DeepThoughtsE<gt>
68 or send mail to E<lt>bug-Acme-DeepThoughts#rt.cpan.orgE<gt>
69
70
71 =head1 AUTHOR
72
73 D. H. (PODMASTER)
74
75 =head1 COPYRIGHT
76
77 This program is free software; you can redistribute
78 it and/or modify it under the same terms as Perl itself.
79
80 The full text of the license can be found in the
81 LICENSE file included with this module.
82
83
84 =head1 SEE ALSO
85
86 L<Acme::Bushisms|Acme::Bushisms>, L<Acme::Bleach|Acme::Bleach>,.
87
88 =cut
89
90 __DATA__
↑ Summary