| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Acme::Laugh; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 2 |  |  | 2 |  | 40463 | use version; $VERSION = qv('0.0.5'); | 
|  | 2 |  |  |  |  | 3827 |  | 
|  | 2 |  |  |  |  | 11 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 2 |  |  | 2 |  | 125 | use warnings; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 47 |  | 
| 6 | 2 |  |  | 2 |  | 8 | use strict; | 
|  | 2 |  |  |  |  | 8 |  | 
|  | 2 |  |  |  |  | 41 |  | 
| 7 | 2 |  |  | 2 |  | 13 | use Carp; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 160 |  | 
| 8 | 2 |  |  | 2 |  | 9 | use Exporter; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 856 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | our @ISA = qw( Exporter ); | 
| 11 |  |  |  |  |  |  | our %EXPORT_TAGS = ('all' => [qw( laugh )]); | 
| 12 |  |  |  |  |  |  | our @EXPORT_OK   = (@{$EXPORT_TAGS{'all'}}); | 
| 13 |  |  |  |  |  |  | our @EXPORT      = qw(); | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | # Module implementation here | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | my @incipit = ('', qw( m b mb )); | 
| 18 |  |  |  |  |  |  | my @alto    = qw( w u ); | 
| 19 |  |  |  |  |  |  | my @basso   = qw( a e ); | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | =encoding iso-8859-1 | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | =begin Private | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | =over | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | =item incipit() | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | Returns the incipit of the laugh. No parameters. | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | =item minichunk( $first ); | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | Returns a chunk of a laugh. It is compound of one to three letters. | 
| 34 |  |  |  |  |  |  | The input parameter forces the inclusion of the first letter, for reasons | 
| 35 |  |  |  |  |  |  | too difficult to explain here. | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | =item continuum( $chunks ); | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | Returns the join of a $chunks number of elements, where $chunks defaults | 
| 40 |  |  |  |  |  |  | to 1 + rand 4; | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | =item capitals( $laugh ); | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | Returns the input $laugh where some of the letters are capitalised in | 
| 45 |  |  |  |  |  |  | a random fashion. | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | =back | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | =end Private | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | =cut | 
| 52 |  |  |  |  |  |  |  | 
| 53 | 2 |  |  | 2 | 1 | 94 | sub incipit { return $incipit[rand @incipit]; } | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | sub minichunk { | 
| 56 | 20 |  |  | 20 | 1 | 23 | my ($dopre) = @_; | 
| 57 | 20 |  |  |  |  | 43 | my $pre = $alto[rand @alto]; | 
| 58 | 20 | 100 | 100 |  |  | 80 | $pre = '' if (!$dopre) && (rand > 0.5); | 
| 59 | 20 | 100 |  |  |  | 37 | my $post = (rand > 0.5) ? 'h' : ''; | 
| 60 | 20 |  |  |  |  | 51 | my $chunk = join '', $pre, $basso[rand @basso], $post; | 
| 61 | 20 |  |  |  |  | 56 | return ($chunk, $post); | 
| 62 |  |  |  |  |  |  | } ## end sub minichunk | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | sub continuum { | 
| 65 | 2 |  | 50 | 2 | 1 | 11 | my $chunks = shift || 0; | 
| 66 | 2 | 50 |  |  |  | 17 | $chunks = 1 + rand 4 if $chunks < 1; | 
| 67 | 2 |  |  |  |  | 5 | my $p = 0; | 
| 68 | 20 |  |  |  |  | 36 | return join '', | 
| 69 | 2 |  |  |  |  | 8 | map { (my $c, $p) = minichunk(!$p); $c; } 1 .. $chunks; | 
|  | 20 |  |  |  |  | 46 |  | 
| 70 |  |  |  |  |  |  | } ## end sub continuum | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | sub capitals { | 
| 73 | 2 | 100 |  | 2 | 1 | 43 | return join '', map { rand > 0.5 ? uc($_) : $_; } split //, shift; | 
|  | 45 |  |  |  |  | 121 |  | 
| 74 |  |  |  |  |  |  | } | 
| 75 |  |  |  |  |  |  |  | 
| 76 | 2 |  |  | 2 | 1 | 403 | sub laugh { return capitals(join '', incipit(), continuum(shift)); } | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | 1;    # Magic true value required at end of module | 
| 79 |  |  |  |  |  |  | __END__ |