Automatic Drug and Aphex Twin Song Name Generator

(thing) by mkb Sat Mar 30 2002 at 10:38:43
This is a goofy little web gimmick I made up one day. If you would like to use it on the web, you'll have to host it yourself!

You can also use it in #everything by asking CowbotNeal "be aphex twin".

#!/usr/bin/perl -w

use strict;
use CGI;

my $query = new CGI;

if ($query->param("viewsource")) {
	print "Content-type: text/plain\n\n";
	open(SOURCE,"medicalname");
	while (<SOURCE>) {
		print;
	}
} else {

	print "Content-type: text/html\n\n";

	my @ends = qw(
	amine
	ophan
	aline
	etine
	ogen
	anine
	anol
	ophlex
	aphlex
	ia
	ane
	ene
	ine
	ite
	ate
	ation
	ose
	ose
	ase
	idine
	ax
	il
	ide
	);

	my @bridges = qw(
	afro
	estro
	iso
	ama
	etho
	ecto
	endo
	exo
	oli
	orli
	oxy
	obo
	ono
	);

	my @starts = qw(
	floozy
	trypto
	pro
	proto
	gyno
	andro
	miso
	poly
	hemato
	cyclo
	pneuma
	ma
	toma
	grappa
	logi
	logo
	lipo
	deca
	pneumo
	chloro
	fluoro
	hydro
	flu
	contra
	);

	my @vowelmiddles = qw(
	easter
	acu
	at
	in
	am
	eth
	al
	orl
	ornith
	ox
	estr
	);

	my @middles = qw(
	sertr
	protein
	plasmic
	skeletal
	trypt
	punct
	par
	gen
	pax
	clemast
	hemat
	mis
	fromag
	phenyl
	prop
	wank
	lip
	foz
	dextr
	fruct
	clem
	chlor
	nom
	chees
	meth
	but
	stat
	fumar
	phobic
	ponic
	);

	my $numsyllables;
	my $name = "";

	my $numwords = $query->param("numwords")||1;

	for (;$numwords > 0; --$numwords) {
		my $numsyllables = $query->param("numsyllables")||int( 1 + rand(6));
		my @syllables;
		$syllables[$numsyllables] = $ends[int(rand() * $#ends)];
	
		my $vowel = 1;


		for ( --$numsyllables; $numsyllables >= 0; --$numsyllables) {
			my @parts;
			my $part;
			if ($vowel) {
				@parts = (@middles,@vowelmiddles);
				$part = int(rand()*$#parts);
				$vowel = ($part > $#middles);
			} else {
				@parts = (@starts,@bridges);
				$part = int(rand()*$#parts);
				$vowel = ($part > $#starts);
			}
	
			$syllables[$numsyllables] = $parts[$part];
	
		}
	
		$name .= (join("",@syllables));
		$name .= " " if $numwords>1;
	}
	
	$name = ucfirst($name);

	if ($query->param("suffix")) {
		my $suffix = $query->param("suffix");
		$suffix =~ s/\-//g;
		$name .= "-".$suffix;
	} elsif (rand() > 0.75) {
	#if (rand() > 0.75) {
		$name .= "-".chr(65+rand()*26);
	}

	my @params = $query->param();
	my $querystring = join("&",map {"$_=".$query->param($_)} @params);
if ($query->param("mode") eq "xml") {
	print <<EOT;
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns="http://purl.org/rss/1.0/"
 xmlns:dc="http://purl.org/dc/elements/1.1/"
 xmlns:syn="http://purl.org/rss/1.0/modules/syndication/"
 xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/"
>

<channel rdf:about="http://www.ele.uri.edu/cgi-bin/user/mkb/medicalname?mode=xml">

<title>Drug Name Generator</title>
<link>http://www.ele.uri.edu/cgi-bin/user/mkb/medicalname?mode=xml</link>
<description></description>

<items>
<rdf:Seq>
<rdf:li rdf:resource="http://www.ele.uri.edu/cgi-bin/user/mkb/medicalname?mode=xml" />
</rdf:Seq>
</items>
</channel>

<item rdf:about="http://www.ele.uri.edu/cgi-bin/user/mkb/medicalname?mode=xml">
<title>$name</title>
<link>http://www.ele.uri.edu/cgi-bin/user/mkb/medicalname?mode=xml</link>
</item>

</rdf:RDF>
EOT
	} else {

	print <<EOT;
<HTML><HEAD><TITLE>Automatic Drug and Aphex Twin Song Name Generator</title></head>

<BODY>
<H1>$name</h1><BR />

<A HREF="medicalname?$querystring">AGAIN!</a><BR />
<form action="medicalname" method="get">
change options!<br>
number of word parts <input type="text" name="numsyllables"><br>
suffix <input type="text" name="suffix"><br>
number of words <input type="text" name="numwords"><br>
<input type="Submit" value="Submit">
<A HREF="medicalname?viewsource=yes"></form>
<br>
View source</a>

</body></html>
EOT
	}
}
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.