#!/usr/bin/perl # 6/12/07 # bullpaper.pl # a bullpaper title generator # by gorlist # ./bullpaper -h to display usage info # thanks go to sin for helping me with the wordlist # http://www.int0x80.gr/code/bullpaper.txt # http://www.int0x80.gr/code/words.txt # both bullpaper.pl and words.txt are needed use warnings; use strict; use List::Util 'shuffle'; my $program=$0; my $level=shift; my $file="words.txt"; open FH, $file or die "File does not exist"; my @words=; my $text=join '',@words; my ($adjL)= $text =~ m/~([^]]+)~/; my ($adjM)= $text =~ m/!([^]]+)!/; my ($adjH)= $text =~ m/\@([^]]+)\@/; my ($nounL)= $text =~ m/#([^]]+)#/; my ($nounM)= $text =~ m/\$([^]]+)\$/; my ($nounH)= $text =~ m/%([^]]+)%/; my ($adv)= $text =~ m/\^([^]]+)\^/; close FH; my @adjLow=split '\n',$adjL; my @adjMed=split '\n',$adjM; my @adjHigh=split '\n',$adjH; my @nounLow=split '\n',$nounL; my @nounMed=split '\n',$nounM; my @nounHigh=split '\n',$nounH; my @adverbs=split '\n',$adv; my @adjAll=(@adjLow,@adjMed,@adjHigh); my @adjs=shuffle(@adjAll); my @nounAll=(@nounLow,@nounMed,@nounHigh); my @nouns=shuffle(@nounAll); my @glueLow=( 'of', 'for', 'in' ); my @glueMed=( ['of','in'], ['for','of'], ['in','and'], ['in','for'], ['and','in'], ['and','of'] ); my @glueHigh=( ['of','and','for'], ['of','and','in'], ['of','in','of'], ['of','using','for'] ); my @glueAll=( ['of','in'], ['for','of'], ['in','and'], ['in','for'], ['and','in'], ['and','of'], ['of','and','for'], ['of','and','in'], ['of','in','of'] ); my $i; my $c=0; my $n; my $a; my $g; my $ad; my $elemLow=@glueLow; my $numLow=int rand $elemLow; my $elemMed=@glueMed; my $numMed=int rand $elemMed; my $elemHigh=@glueHigh; my $numHigh=int rand $elemHigh; my $elemAll=@glueAll; my $numAll=int rand $elemAll; if (defined $level){ if ($level eq "undergraduate" or $level eq "bsc"){ $a=@adjLow[rand @adjLow]; $n=@nounLow[rand @nounLow]; $g=@glueLow[rand @glueLow]; print ucfirst "$a "; $a=@adjLow[rand @adjLow]; print "$a "; print "$n "; print "$g "; $a=@adjLow[rand @adjLow]; $n=@nounLow[rand @nounLow]; print "$a "; print "$n"; if (substr ($n,-1) ne "s"){ print "s"; } print "\n\n"; } elsif ($level eq "postgraduate" or $level eq "msc"){ $a=@adjMed[rand @adjMed]; $n=@nounMed[rand @nounMed]; $g=$glueMed[$numMed][$c]; print ucfirst "$a "; print "$n "; print "$g "; $c++; $a=@adjMed[rand @adjMed]; $n=@nounMed[rand @nounMed]; $g=$glueMed[$numMed][$c]; print "$a "; print "$n "; print "$g "; $a=@adjMed[rand @adjMed]; $n=@nounMed[rand @nounMed]; print "$a "; $a=@adjMed[rand @adjMed]; print "$a "; print "$n"; if (substr ($n,-1) ne "s"){ print "s"; } print "\n\n"; } elsif ($level eq "professor" or $level eq "phd"){ $a=@adjHigh[rand @adjHigh]; $n=@nounHigh[rand @nounHigh]; $g=$glueHigh[$numHigh][$c]; $ad=@adverbs[rand @adverbs]; print ucfirst "$a "; print "$n "; print "$g "; $c++; $a=@adjHigh[rand @adjHigh]; $n=@nounHigh[rand @nounHigh]; $g=$glueHigh[$numHigh][$c]; print "$a "; print "$n "; print "$g "; $c++; $a=@adjHigh[rand @adjHigh]; $n=@nounHigh[rand @nounHigh]; $g=$glueHigh[$numHigh][$c]; print "$a "; $a=@adjHigh[rand @adjHigh]; print "$a "; print "$n "; print "$g "; print "$ad "; $a=@adjHigh[rand @adjHigh]; $n=@nounHigh[rand @nounHigh]; print "$a "; print "$n"; if (substr ($n,-1) ne "s"){ print "s"; } print "\n\n"; } else{ usage(); } } else{ for ($i=0;$i<3;$i++){ $n=@nouns[rand @nouns]; $a=@adjs[rand @adjs]; $g=$glueAll[$numAll][$i]; if ($i==0){ print ucfirst "$a "; print "$n "; } else{ print "$a "; print "$n "; } if (defined ($glueAll[$numAll][$i])){ print $g." "; } } $n=@nouns[rand @nouns]; $a=@adjs[rand @adjs]; print "$a "; print "$n"; if (substr ($n,-1) ne "s"){ print "s"; } print "\n\n"; } sub usage{ print "\n\n"; print "bullpaper - a bullpaper title generator\n"; print " by gorlist\n\n"; print "Usage:\n $program [ bsc | msc | phd ]\n"; print "or $program [ undergraduate | postgraduate | professor ]\n"; print "or just $program for a non-specific bullresult (uses all words)\n"; print "\n\n"; }