#!/usr/bin/perl require "BrunchingHTML.pl"; my setup_brunching_vars( "author" => "fs", "section" => "toys", "title" => "C.Y.B.O.R.G.", "s_title" => "cyborger", "revision" => 2, ); use CGI; my $q; my $acname; my $myname; my $originalname = ""; my $template; my $letters; my $length; my $length1; my $wordtype; my $letter; my $firstword; my $secondword; my $tempword; my $highscore; my $score; my $goodname; my $firstletter; my $fullname; my $output; my @name = (); my %words = (); my %score = (); my %done = (); my %wordtype = (); my @letters = (); $q = new CGI; $myname = $q->param('acronym'); $myname = uc($myname); $myname =~ s/[^A-Z]//g; $acname = $myname; $originalname = $myname; $acname =~ s/([A-Z])/$1\./g; &PrintOut("Names must be at least two letters long. Pretty strange from a guy calling himself \"L.\", but there you go.") if (length $myname < 2); &PrintOut("Names can't be more than eleven letters, so use a nickname. How about \"Tiger\"?") if (length $myname > 11); if (length $myname > 8) { $length1 = 5; $name[0] = substr $myname, 0, $length1; $name[1] = substr $myname, $length1; } else { $name[0] = $myname; } foreach $myname (@name) { $words{2} = ([ "TYPEADJ TYPENOUN", "PURPOSENOUN TYPENOUN" ]); $words{3} = ([ "TYPENOUN ORIGVERB PURPOSENOUN", "TYPEADJ TYPEADJ TYPENOUN", "TYPEADJ PURPOSENOUN TYPENOUN", "PURPOSENOUN and PURPOSENOUN TYPENOUN", "PURPOSEADJ PURPOSENOUN TYPENOUN" ]); $words{4} = ([ "TYPENOUN ORIGVERB PURPOSENOUN and PURPOSENOUN", "TYPENOUN ORIGVERB PURPOSEADJ PURPOSENOUN", "TYPEADJ TYPENOUN ORIGVERB PURPOSENOUN", "TYPEADJ TYPEADJ PURPOSENOUN TYPENOUN", "TYPEADJ PURPOSENOUN and PURPOSENOUN TYPENOUN", "TYPEADJ PURPOSEADJ PURPOSENOUN TYPENOUN", "PURPOSENOUN and PURPOSEADJ PURPOSENOUN TYPENOUN", "PURPOSEADJ PURPOSENOUN and PURPOSENOUN TYPENOUN", ]); $words{5} = ([ "TYPENOUN ORIGVERB PURPOSENOUN and PURPOSEADJ PURPOSENOUN", "TYPENOUN ORIGVERB PURPOSEADJ PURPOSENOUN and PURPOSENOUN", "TYPEADJ TYPENOUN ORIGVERB PURPOSENOUN and PURPOSENOUN", "TYPEADJ TYPENOUN ORIGVERB PURPOSEADJ PURPOSENOUN", "TYPEADJ TYPEADJ TYPENOUN ORIGVERB PURPOSENOUN", "TYPEADJ TYPEADJ PURPOSENOUN and PURPOSENOUN TYPENOUN", "TYPEADJ TYPEADJ PURPOSEADJ PURPOSENOUN TYPENOUN", "TYPEADJ PURPOSENOUN and PURPOSEADJ PURPOSENOUN TYPENOUN", "TYPEADJ PURPOSEADJ PURPOSENOUN and PURPOSENOUN TYPENOUN", ]); $words{6} = ([ "TYPEADJ TYPENOUN ORIGVERB PURPOSENOUN and PURPOSEADJ PURPOSENOUN", "TYPEADJ TYPENOUN ORIGVERB PURPOSEADJ PURPOSENOUN and PURPOSENOUN", "TYPEADJ TYPEADJ TYPENOUN ORIGVERB PURPOSENOUN and PURPOSENOUN", "TYPEADJ TYPEADJ TYPENOUN ORIGVERB PURPOSEADJ PURPOSENOUN", "TYPEADJ TYPEADJ PURPOSENOUN and PURPOSEADJ PURPOSENOUN TYPENOUN", "TYPEADJ TYPEADJ PURPOSEADJ PURPOSENOUN and PURPOSENOUN TYPENOUN", ]); $words{7} = ([ "TYPEADJ TYPEADJ TYPENOUN ORIGVERB PURPOSENOUN and PURPOSEADJ PURPOSENOUN", "TYPEADJ TYPEADJ TYPENOUN ORIGVERB PURPOSEADJ PURPOSENOUN and PURPOSENOUN", ]); $words{8} = ([ "TYPEADJ TYPEADJ TYPENOUN ORIGVERB PURPOSEADJ PURPOSENOUN and PURPOSEADJ PURPOSENOUN", ]); $wordtype{TYPENOUN}{A} = "Android+"; $wordtype{TYPENOUN}{B} = "Being+"; $wordtype{TYPENOUN}{C} = "Construct+"; $wordtype{TYPENOUN}{D} = "Device"; $wordtype{TYPENOUN}{E} = "Entity"; $wordtype{TYPENOUN}{F} = "Facsimile-"; $wordtype{TYPENOUN}{G} = "Guardian--"; $wordtype{TYPENOUN}{H} = "Humanoid"; $wordtype{TYPENOUN}{I} = "Individual"; $wordtype{TYPENOUN}{J} = "Judge--"; $wordtype{TYPENOUN}{K} = "Knight-"; $wordtype{TYPENOUN}{L} = "Lifeform+"; $wordtype{TYPENOUN}{M} = "Machine+"; $wordtype{TYPENOUN}{N} = "Neohuman--"; $wordtype{TYPENOUN}{O} = "Organism"; $wordtype{TYPENOUN}{P} = "Person"; $wordtype{TYPENOUN}{Q} = "Quadruplet--"; $wordtype{TYPENOUN}{R} = "Replicant"; $wordtype{TYPENOUN}{S} = "Soldier-"; $wordtype{TYPENOUN}{T} = "Technician-"; $wordtype{TYPENOUN}{U} = "Unit+"; $wordtype{TYPENOUN}{V} = "Variant-"; $wordtype{TYPENOUN}{W} = "Worker"; $wordtype{TYPENOUN}{X} = "Xenomorph"; $wordtype{TYPENOUN}{Y} = "Youth--"; $wordtype{TYPENOUN}{Z} = "Zombie-"; $wordtype{TYPEADJ}{A} = "Artificial+/Advanced"; $wordtype{TYPEADJ}{B} = "Biomechanical+/Bionic"; $wordtype{TYPEADJ}{C} = "Cybernetic+/Clockwork"; $wordtype{TYPEADJ}{D} = "Digital/Deadly"; $wordtype{TYPEADJ}{E} = "Electronic+/Engineered"; $wordtype{TYPEADJ}{F} = "Functional/Fusion-"; $wordtype{TYPEADJ}{G} = "General-/Genius--"; $wordtype{TYPEADJ}{H} = "Hydraulic-/Handcrafted-"; $wordtype{TYPEADJ}{I} = "Intelligent/Inhuman"; $wordtype{TYPEADJ}{J} = "Journeying-/Judicious--"; $wordtype{TYPEADJ}{K} = "Kinetic-/Knowledgable-"; $wordtype{TYPEADJ}{L} = "Lifelike/Lethal"; $wordtype{TYPEADJ}{M} = "Mechanical+/Model-"; $wordtype{TYPEADJ}{N} = "Networked/Nuclear"; $wordtype{TYPEADJ}{O} = "Obedient/Organic"; $wordtype{TYPEADJ}{P} = "Positronic/Patented"; $wordtype{TYPEADJ}{Q} = "Quantum/Quinessential"; $wordtype{TYPEADJ}{R} = "Robotic+/Radioactive"; $wordtype{TYPEADJ}{S} = "Synthetic+/Simulated"; $wordtype{TYPEADJ}{T} = "Transforming-/Thermodynamic--"; $wordtype{TYPEADJ}{U} = "Upgraded/Unique"; $wordtype{TYPEADJ}{V} = "Vigilant/Valuable-"; $wordtype{TYPEADJ}{W} = "Wireless/Watchful-"; $wordtype{TYPEADJ}{X} = "eXperimental+/eXtraterrestrial"; $wordtype{TYPEADJ}{Y} = "Ytterbium--/Youthful--"; $wordtype{TYPEADJ}{Z} = "Zeta--/Zircon--"; $wordtype{PURPOSENOUN}{A} = "Assassination/Analysis"; $wordtype{PURPOSENOUN}{B} = "Battle+/Botany-"; $wordtype{PURPOSENOUN}{C} = "Calculation/Capture-"; $wordtype{PURPOSENOUN}{D} = "Destruction/Deduction"; $wordtype{PURPOSENOUN}{E} = "Exploration+/Education"; $wordtype{PURPOSENOUN}{F} = "Fighting/Fornication-"; $wordtype{PURPOSENOUN}{G} = "Gratification-/Geophysics-"; $wordtype{PURPOSENOUN}{H} = "Harm-/Hunting-"; $wordtype{PURPOSENOUN}{I} = "Infiltration/Instruction-"; $wordtype{PURPOSENOUN}{J} = "Judo-/Jobs--"; $wordtype{PURPOSENOUN}{K} = "Killing+/Kindness--"; $wordtype{PURPOSENOUN}{L} = "Learning-/Law-"; $wordtype{PURPOSENOUN}{M} = "Mathematics/Murder"; $wordtype{PURPOSENOUN}{N} = "Nullification--/Negotiation-"; $wordtype{PURPOSENOUN}{O} = "Observation/Obliteration-"; $wordtype{PURPOSENOUN}{P} = "Peacekeeping/Patrol--"; $wordtype{PURPOSENOUN}{Q} = "Questioning-/Quantification-"; $wordtype{PURPOSENOUN}{R} = "Repair/Reasoning"; $wordtype{PURPOSENOUN}{S} = "Sabotage/Surveillance-"; $wordtype{PURPOSENOUN}{T} = "Troubleshooting/Tactics-"; $wordtype{PURPOSENOUN}{U} = "Utility-/Uplink-"; $wordtype{PURPOSENOUN}{V} = "Violence+/Vengance"; $wordtype{PURPOSENOUN}{W} = "Warfare/Wrecking--"; $wordtype{PURPOSENOUN}{X} = "Xenocide/eXecution"; $wordtype{PURPOSENOUN}{Y} = "Yardwork--/Yield--"; $wordtype{PURPOSENOUN}{Z} = "Zoology-/Zymurgy--"; $wordtype{PURPOSEADJ}{A} = "Accurate"; $wordtype{PURPOSEADJ}{B} = "Basic"; $wordtype{PURPOSEADJ}{C} = "Ceaseless"; $wordtype{PURPOSEADJ}{D} = "Dangerous"; $wordtype{PURPOSEADJ}{E} = "Efficient+"; $wordtype{PURPOSEADJ}{F} = "Forbidden"; $wordtype{PURPOSEADJ}{G} = "Galactic"; $wordtype{PURPOSEADJ}{H} = "Hazardous"; $wordtype{PURPOSEADJ}{I} = "Intensive-"; $wordtype{PURPOSEADJ}{J} = "Justified-"; $wordtype{PURPOSEADJ}{K} = "Kamikaze-"; $wordtype{PURPOSEADJ}{L} = "Logical"; $wordtype{PURPOSEADJ}{M} = "Mandatory"; $wordtype{PURPOSEADJ}{N} = "Nocturnal-"; $wordtype{PURPOSEADJ}{O} = "Online"; $wordtype{PURPOSEADJ}{P} = "Potential"; $wordtype{PURPOSEADJ}{Q} = "Quick"; $wordtype{PURPOSEADJ}{R} = "Rational-"; $wordtype{PURPOSEADJ}{S} = "Scientific"; $wordtype{PURPOSEADJ}{T} = "Terran"; $wordtype{PURPOSEADJ}{U} = "Ultimate"; $wordtype{PURPOSEADJ}{V} = "Vigilant"; $wordtype{PURPOSEADJ}{W} = "Worldwide"; $wordtype{PURPOSEADJ}{X} = "eXpert"; $wordtype{PURPOSEADJ}{Y} = "Your--"; $wordtype{PURPOSEADJ}{Z} = "Zealous"; $wordtype{ORIGVERB}{A} = "Assembled for"; $wordtype{ORIGVERB}{B} = "Built for"; $wordtype{ORIGVERB}{C} = "Calibrated for"; $wordtype{ORIGVERB}{D} = "Designed for+"; $wordtype{ORIGVERB}{E} = "Engineered for+"; $wordtype{ORIGVERB}{F} = "Fabricated for"; $wordtype{ORIGVERB}{G} = "Generated for"; $wordtype{ORIGVERB}{H} = "Hardwired for"; $wordtype{ORIGVERB}{I} = "Intended for"; $wordtype{ORIGVERB}{J} = "Justified for--"; $wordtype{ORIGVERB}{K} = "Keen on"; $wordtype{ORIGVERB}{L} = "Limited to"; $wordtype{ORIGVERB}{M} = "Manufactured for"; $wordtype{ORIGVERB}{N} = "Normally for--"; $wordtype{ORIGVERB}{O} = "Optimized for+"; $wordtype{ORIGVERB}{P} = "Programmed for+"; $wordtype{ORIGVERB}{Q} = "Qualified for"; $wordtype{ORIGVERB}{R} = "Responsible for"; $wordtype{ORIGVERB}{S} = "Skilled in"; $wordtype{ORIGVERB}{T} = "Trained for"; $wordtype{ORIGVERB}{U} = "Used for"; $wordtype{ORIGVERB}{V} = "Viable for"; $wordtype{ORIGVERB}{W} = "Wanting--"; $wordtype{ORIGVERB}{X} = "eXperienced in"; $wordtype{ORIGVERB}{Y} = "Yearning for-"; $wordtype{ORIGVERB}{Z} = "Zoned for--"; #### Main Part $length = length $myname; @letters = split(//,$myname); $highscore = -99; $goodname = ""; foreach $template (@{$words{$length}}) { $score = 0; %done = (); foreach $letter (@letters) { if ($template =~ /(\b[A-Z]+\b)/) { $wordtype = $1; $tempword = $wordtype{$wordtype}{$letter}; if ($tempword =~ /(.*)\/(.*)/) { $firstword = $1; $secondword = $2; if (! $done{$firstword}) { $tempword = $firstword; $done{$firstword}++; } else { $tempword = $secondword; } } if ($fullname =~ /\b$tempword\b/) { $score--; } if ($tempword =~ s/\+\+$//) { $score += 2; } elsif ($tempword =~ s/\+$//) { $score++; } elsif ($tempword =~ s/\-\-$//) { $score -= 2; } elsif ($tempword =~ s/\-$//) { $score--; } $template =~ s/(\b[A-Z]+\b)/$tempword/; } } $score{$template} = $score; $score -= 100 if $template eq $fullname; if ($score > $highscore) { $goodname = $template; $highscore = $score; } } if ($fullname) { $fullname .= "/$goodname"; } else { $fullname = $goodname; } } $firstletter = substr($originalname,0,1); unless (-e "../cybimages/$firstletter/cyb-$originalname.gif") { &StoreGif($originalname,$fullname); } $output .= "$acname: $fullname"; open(LOG,">>cyborger-log.txt"); print LOG "$output\n"; close(LOG); &PrintOut("
$output
<A HREF="http://brunching.com/toys/cyborger.html"><IMG SRC="http://www.brunching.com/cybimages/$firstletter/cyb-$originalname.gif" WIDTH=240 HEIGHT=150 ALT="$fullname" BORDER=0></A>
EOFILE } else { print <$output
EOFILE } print &brunching_footer; exit; } sub StoreGif { use GD; my $acronym = shift; my $fullname = shift; my $gif; my $word; my @words; my $maxlength; my $leftmargin; my $topmargin; my $img; my $black; my $white; my $red; my $leftmost; my $w; my $h; my $printx; my $printy; $gif = "../images/mycyborg-lossy.gif"; $fullname =~ s#/#/ #; @words = split(/ (?=[A-Z])/,$fullname); for $word (@words) { $maxlength = length $word if length $word > $maxlength; } $leftmargin = 110 + ((17 - $maxlength) * 3); $topmargin = 6 + (11 - @words); open(GIF,"$gif") || die "Can't open $gif: $!\n"; $img = newFromGif GD::Image(GIF); close(GIF); $black = $img->colorAllocate(40,40,40); $white = $img->colorAllocate(255,255,255); $red = $img->colorAllocate(255,75,75); ($w,$h) = (gdMediumBoldFont->width,gdMediumBoldFont->height); $h-- if @words == 11; $h = $h + 2 if @words <= 5; $printx = $leftmargin; $printy = $topmargin; foreach $word (@words) { $img->string(gdMediumBoldFont,$printx + 1,$printy + 1,$word,$white); $img->string(gdMediumBoldFont,$printx,$printy,$word,$black); $printy += $h; } $leftmost = 15 + ((11 - length $originalname) * 3.5); $img->string(gdMediumBoldFont,$leftmost,110,$originalname,$red); my $firstletter = substr($acronym,0,1); open(GIF,">../cybimages/$firstletter/cyb-$acronym.gif") or return; print GIF $img->gif; close GIF; return 1; }