Skip to content

Instantly share code, notes, and snippets.

@drj42
Created October 29, 2013 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drj42/7221275 to your computer and use it in GitHub Desktop.
Save drj42/7221275 to your computer and use it in GitHub Desktop.
Mojolicious ingress cemetery portal name generator
#!/usr/bin/env perl
use Mojolicious::Lite;
# Instructions:
# $ cpanm Mojolicious
# $ morbo grave_names.pl
#
# browse to http://localhost:3000
# Documentation browser under "/perldoc"
# plugin 'PODRenderer';
my @adjectives = (
"lonely", "little", "blackstone", "headless","decapitated","defecating","brony"
);
my @verbs = (
"watching", "weeping","looking", "staring", "heaving", "crying","sitting","sleeping","stalking","shaving"
);
my @subjects = (
"woodmen","child","lamb","sheep","tony","hammer","stache"
);
my @nouns = (
"mausoleum", "memorial", "grave marker","headstone","stump","burial site"
);
get '/' => sub {
my $me = shift;
my $name = generate_name();
$me->stash(name => $name);
$me->render('index');
};
sub rand_el { $_[int(rand(@_))] }
sub generate_name {
join " ", (ucfirst rand_el(@adjectives),
ucfirst rand_el(@verbs),
ucfirst rand_el(@subjects),
ucfirst rand_el(@nouns))
}
app->start;
__DATA__
@@ index.html.ep
% layout 'default';
% title 'Refresh the page to get a new name!';
<strong><%= $name %></strong>
<br />
<br />
<a href="/">generate another</a>
@@ layouts/default.html.ep
<!DOCTYPE html>
<html>
<head><title><%= title %></title></head>
<body><%= content %></body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment