Acme-Daily-Fail
view release on metacpan or search on metacpan
lib/Acme/Daily/Fail.pm view on Meta::CPAN
"the queen", # God bless 'er
"the king", # God bless 'im
"the royal family",
"the church",
"you",
"your mortgage",
"your pension",
"your daughters",
"your children",
"your house",
"your pets",
"the conservative party", # FAIL
"cliff richard", # Should this be in here?
"the memory of diana",
"Britain's swans", # This always stays
"Brexit",
];
# Matches an auxiliary verb with the subject
sub _match_verb_and_subject {
my ($subject,$verb) = @_;
if ($subject->[NUMBER] == 1 && $subject->[PERSON] == 3) {
return $verb->[SINGULAR];
}
else {
return $verb->[PLURAL];
}
}
# Matchs the transitive verb's tense with that of the verb
#function Phrase(present, past, active, object) {
sub _match_verb_and_tense {
my ($verb,$phrase) = @_;
if ($verb->[TENSE] eq "present") {
return $phrase->[PRESENT];
}
elsif ($verb->[TENSE] eq "past") {
return $phrase->[PAST];
}
elsif ($verb->[TENSE] eq "active") {
return $phrase->[ACTIVE];
}
}
# Returns a Daily Mail Headline as a string
sub get_headline {
my @sentence;
my $subject = _getRandom($subjects);
my $phrase = _getRandom($transitive_phrases);
my $verb = _getRandom($auxiliary_verbs);
my $object = _getRandom($objects);
$sentence[0] = _match_verb_and_subject($subject, $verb);
$sentence[1] = $subject->[WORD];
$sentence[2] = _match_verb_and_tense($verb, $phrase);
$sentence[3] = $object;
$sentence[4] = $phrase->[OBJECT] if $phrase->[OBJECT];
my $s = join ' ', map { uc } @sentence;
$s .= '?';
return $s;
}
qq[BLOODY IMMIGRANTS];
__END__
=pod
=encoding UTF-8
=head1 NAME
Acme::Daily::Fail - generate random newspaper headlines
=head1 VERSION
version 1.24
=head1 SYNOPSIS
use strict;
use warnings;
use Acme::Daily::Fail qw(get_headline);
print get_headline(), "\n";
=head1 DESCRIPTION
Acme::Daily::Fail provides a single function that when called generates a
random newspaper headline which is typical for a certain UK newspaper title.
=head1 NAME
=head1 FUNCTION
=over
=item C<get_headline>
Not exported by default, takes no parameters, returns a randomly generated headline.
=back
=head1 BASED ON
Based on the Daily-Mail-o-matic by Chris Applegate
L<http://www.qwghlm.co.uk/toys/dailymail/>
=head1 SEE ALSO
L<http://www.qwghlm.co.uk/toys/dailymail/>
=head1 AUTHOR
Chris Williams <chris@bingosnet.co.uk>
( run in 2.519 seconds using v1.01-cache-2.11-cpan-8f98c5d2c55 )