Hey everybody,
Thanks for all your help on my last problem, Heres my lastest stummper. Bare with me now...
O.k I'm trying to create a random image generator or some such thing like that. Just experimenting really. But I've kind of come to a dead end. When I try run the following code I get two errors(that I can see, because the help scrolls out of the screen in dos):
Useless use of private variable in void context at rand.pl line 38 (#2 +) Useless use of a constant in void context at rand.pl line 25 (#2)
Now this proves to be a wee bit confusing... Take the latter of the two, this refers to the MainLoop; function which, correct me if I'm wrong, tells perl to stop drawing widgets and start looking at the subs.
But I copied and pasted the origonal canvas code that I used from another script which works perfect.
CONFUSING, NO?

Here is the code:
use warnings; use diagnostics; use TK; my (@coLour, $COLOUR, @list, @tmplist, $key); my $width = 600; my $height = 600; my $i = 0; my $randi = &randi(); my $mw=MainWindow->new; my $canvas =$mw->Canvas(width => $width, height => $height)->pack(); for($i = 0; $i < $randi; $i += 1){ my $colour = &colour(); my @tmp = &xy(); $canvas->create('line', $tmp[0], $tmp[1], $tmp[2], $tmp[3], -fill +=> $colour); } MainLoop; sub colour{ @coLour = ('red', 'blue', 'green', 'black', 'orange', 'yellow'); $COLOUR = $coLour[int(rand(6))]; return $COLOUR; } sub xy{ @list = ( 1, 2, 3, 4); @tmplist; $key; foreach $key(@list){ my $temp = rand($width); push(@tmplist, $temp); } return @tmplist; } sub randi{ my $temp = rand(50); return $temp; }
Any help would be greatly appricated, and I know it is probrably a stupid mistake but can't see it.
Thanks in Advance.
All the Best, Eoin...

If everything seems to be going well, you obviously don't know what the hell is going on.


In reply to 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.