#!/usr/bin/perl use strict; use warnings; use diagnostics; use Tk; srand; my $timelimits = 1; my @numbers = (1..10); my @building = ("Building"); my @adverb = ("Adverb"); my @verb = ("Verb"); my $mw = new MainWindow; my $title = $mw -> Label(-text=>"Starcraft Strategy Generator") -> grid(); my $howmany = $mw -> Label(-text=>"How many strategies?") -> grid(); my $ent = $mw -> Entry() -> grid(); my $button = $mw -> Button(-text=>"Generate Strategies", -command => \&push_button) -> grid(); my $checkminutes = $mw -> Checkbutton(-text=>"Use time limits?", -variable=>\$timelimits) -> grid(); $checkminutes -> deselect(); my $output = $mw -> Text(-width=>500, -height=> 240) -> pack(); MainLoop; sub push_button { my $builds = $ent -> get(); while(0<$builds) { if($timelimits == 1) { my $numbersrand = rand @numbers; my $buildingrand = rand @building; my $adverbrand = rand @adverb; my $verbrand = rand @verb; my $numbersout = $numbers[$numbersrand]; my $minuteout = "Minute"; my $buildingout = $building[$buildingrand]; my $adverbout = $adverb[$adverbrand]; my $verbout = $verb[$verbrand]; $output -> insert('end',"$numbersout $minuteout $buildingout $adverbout $verbout\n"); $builds --; } else { my $numbersrand = rand @numbers; my $buildingrand = rand @building; my $adverbrand = rand @adverb; my $verbrand = rand @verb; my $numbersout = $numbers[$numbersrand]; my $buildingout = $building[$buildingrand]; my $adverbout = $adverb[$adverbrand]; my $verbout = $verb[$verbrand]; $output -> insert("$numbersout $buildingout $adverbout $verbout\n"); $builds --; } } $output -> insert("Done\n"); }