Hey guys, I somehow screwed up this code. When it runs, it compiles fine, but then it just opens a blank command prompt window. Tk is installed properly, and I can get a basic hello world program running perfectly. Pretty much everything inside sub push_button is from an old program, and I know it works fine. The arrays normally have much more stuff in them.

#!/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") -> gri +d(); 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?", -vari +able=>\$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 $adverbou +t $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"); }

In reply to Tk problem by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.