The main problem is that you have "use TK;" when you should have "use Tk;" (lowercase k). You should also have "use strict;". The "useless" warnings come from these lines:
	@tmplist;
	$key;
Update: You have a bug, by the way. You really should have my @tmplist; inside the sub xy, so it is initialized each time. Right now you keep adding on to a global array, but you keep using the same four coordinates from the beginning of the array. Since I'm feeling generous today--okay, I'm just avoiding my own work--here is the corrected program, with some stylistic improvements (IMHO):
use warnings; use diagnostics; use Tk; use strict; my @coLour = ('red', 'blue', 'green', 'black', 'orange', 'yellow'); my $width = 600; my $height = 600; my $randi = &randi(); my $mw=MainWindow->new; my $canvas =$mw->Canvas(width => $width, height => $height)->pack(); for (1 .. $randi) { $canvas->create('line', &xy(), -fill => &randcolour()) } MainLoop; sub randcolour{ return $coLour[rand(@coLour)]; } sub xy{ my @tmplist; foreach (1 .. 4) { push @tmplist, rand($width); } return @tmplist; } sub randi{ return rand(50); }

In reply to Re: Trouble Tracks Tk by Thelonius
in thread Trouble Tracks Tk by eoin

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.