Acme-ConspiracyTheory-Random
view release on metacpan or search on metacpan
lib/Acme/ConspiracyTheory/Random.pm view on Meta::CPAN
next if length($string) >= 20;
my @letters = split //, $string;
my @numbers = map /[A-Z]/ ? ( ord($_) - 0x40 ) : $_, @letters;
my $sum = List::Util::sum( @numbers );
push @{ $calcs{$sum} ||= [] }, sprintf(
'%s = %s = %s',
join( '+', @letters ),
join( '+', @numbers ),
$sum,
);
}
foreach my $key ( %special_numbers ) {
if ( $calcs{$key} ) {
my @copy = @{ $special_numbers{$key} };
while ( @copy ) {
my ( $test, $statement ) = splice( @copy, 0 , 2 );
next unless "@strings" =~ $test;
push @{ $calcs{$key} }, "And guess what? " . $statement;
}
}
}
my @wow = map { @$_ > 1 ? @$_ : () } values %calcs;
if ( @wow ) {
return sprintf(
"%s %s",
_RANDOM_(
'The numbers never lie.',
'Trust the numbers.',
'You can see the truth in the numbers.',
),
join(
'',
map( "$_. ", @wow ),
)
);
}
return '';
}
sub bad_punctuation {
my ( $string, $cancel ) = @_;
unless ( $cancel ) {
$string =~ s/ ([A-Za-z]) ([,!?]) / $1 . _RANDOM_( $2, " $2", " $2", " $2$2") /exg;
$string =~ s/ ([A-Za-z]) ([.]) / $1 . _RANDOM_($2, $2, " $2", " ", " $2$2$2") /exg;
$string =~ s/\!/_RANDOM_('!', '!', '!!', "!!!!")/ex;
}
return $string;
}
1;
__END__
=pod
=encoding utf-8
=head1 NAME
Acme::ConspiracyTheory::Random - random theories
=head1 SYNOPSIS
use feature 'say';
use Acme::ConspiracyTheory::Random -all;
say bad_punctuation( theory() );
=head1 DESCRIPTION
This module exports a function, C<< theory() >> which returns a string.
=for html <p><img src="https://raw.githubusercontent.com/tobyink/p5-acme-conspiracytheory-random/master/assets/pepe-silvia.jpeg" alt=""></p>
There is also a function C<< bad_punctuation >> which, given a string, might
make the punctuation worse.
=head1 BUGS
Please report any bugs to
L<https://github.com/tobyink/p5-acme-conspiracytheory-random/issues>.
=head1 SEE ALSO
REDACTED
=head1 AUTHOR
Toby Inkster E<lt>tobyink@cpan.orgE<gt>.
=head1 CONTRIBUTORS
Alex Jones discovered that there are secretly other people who have contributed
to this module but Toby Inkster is working with Microsoft and the Illuminati to
cover it up. I tried to blog about it but all my posts keep getting taken down
from Tumblr. There are hidden clues on L<GitHub|https://github.com/tobyink/p5-acme-conspiracytheory-random/graphs/contributors>.
You don't want to know how deep this rabbit hole goes!
=head1 COPYRIGHT AND LICENCE
This software is copyright (c) 2021 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=head1 DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
( run in 2.290 seconds using v1.01-cache-2.11-cpan-0bb4e1dffa6 )