http://qs321.pair.com?node_id=290353


in reply to Re: Re: Tk question
in thread Tk question

OK - maybe my first guess was wrong... :)

If I use "my $t" within this sub and localise it, we wont be referring to the first $t defined outside the sub.Is that right?
Yes - that's right. I thought maybe you were using $t for some other purpose, but it would appear not.

I'm not sure where we should use "my", and where we should not
Check out the section on 'scope' in whatever perl books/docs you have. 'my' declares a variable within the 'current scope' - if that's in a sub (or any pair of braces),it's gone when you exit the sub. If, on the other hand, it's in the 'main body' of your code, it's global oops - I mean file scoped...ermm..global to your file...ermm...you know what I mean - see the AM posting below... . That is generally a Bad Thing.

Turning on use strict gives no message about $t.
Does it give messages about other things? What about use warnings? Fix these, and your problem may possibly go away.

I haven't any more specific ideas, but here are a few general suggestions.

Hope this helps, Ben.