Acme-ConspiracyTheory-Random
view release on metacpan or search on metacpan
lib/Acme/ConspiracyTheory/Random.pm view on Meta::CPAN
19 => [ qr/COVID/, '19 is the coronavirus number' ],
24 => [ qr/TINTIN/, 'There are 24 Tintin comics' ],
33 => [ qr/MASON/, '33 is associated with the masons' ],
35 => [ qr/ELVIS/, 'Elvis was born in 1935' ],
44 => [ qr/OBAMA/, 'Barack Obama was the 44th President of the USA' ],
45 => [ qr/TRUMP|QANON|USA/, 'Donald Trump was the 45th President of the USA',
qr/UNITEDNATIONS/, 'The United Nations was founded in 1945' ],
46 => [ qr/BIDEN/, 'Joe Biden was the 46th President of the USA' ],
47 => [ qr/THECIA/, 'The CIA was founded in 1947',
qr/SILVER/, 'Silver has atomic number 47' ],
49 => [ qr/NATO/, 'NATO was founded in 1949' ],
51 => [ qr/KFC/, 'Area 51 is the fifty-first area' ],
52 => [ qr/KFC/, 'KFC was founded in 1952' ],
55 => [ qr/BIGMAC|MCDONALDS/, 'McDonalds was founded in 1955' ],
63 => [ qr/JFK|OSWALD/, 'JFK was shot in 1963' ],
79 => [ qr/GOLD/, 'Gold has the atomic number 79' ],
81 => [ qr/HIV/, 'AIDS was discovered in 1981' ],
82 => [ qr/COKE/, 'Diet Coke first came out in 1982' ],
86 => [ qr/RADON/, 'The atomic number for radon is 86' ],
92 => [ qr/URANIUM/, 'The atomic number for uranium is 92' ],
322 => [ qr/SKULL/, 'Skull and Bones is Order 322' ],
666 => [ qr/DEVIL|DEMON|SATAN/, '666 is the number of the beast' ],
);
sub numerology {
my $redstring = shift // {};
my @strings = List::Util::uniq(
grep { length }
map { my $letters = uc( $_ ); $letters =~ s/[^A-Z0-9]//g; $letters }
map {
/^(the )(.+)$/i ? $2 : $_
}
map {
ref( $_ ) ? grep( defined, $_->{name}, $_->{shortname}, $_->{title}, $_->{author} ) : $_
}
values( %$redstring )
);
my %calcs;
foreach my $string ( @strings ) {
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
( run in 3.783 seconds using v1.01-cache-2.11-cpan-140bd7fdf52 )