wa4otj has asked for the wisdom of the Perl Monks concerning the following question:
use warnings; my $Timer; my $Display; # This is the Canvas where the widgets are drawn {main code skipped over} sub showProblem { $Timer = $Display->after(shift, sub { $Globalvariable = blah blah blah... $Timer->cancel(); }); }
I get a warning
Variable "$Globalvariable" may be unavailable at some line number...
It seems that putting the global in an anonymous sub is a problem here, although warning aside, the code works perfectly. Yet I have other cases (with the same variable) where Warnings does not complain. Further, if there are two references to $Globalvariable in the anonymous sub, the second one does not generate a warning.
Any clue as to why this might be? I can eliminate the message by the use of "no warnings" in the anonymous sub, but I'm still confused by why I would need to do this. What is the Warnings pragma trying to tell me that I am too stupid to see?
Please educate me...
Nat
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with 'use Warnings' please?
by davorg (Chancellor) on Jul 13, 2009 at 15:47 UTC | |
by JavaFan (Canon) on Jul 13, 2009 at 15:57 UTC | |
by wa4otj (Beadle) on Jul 13, 2009 at 17:00 UTC | |
by davorg (Chancellor) on Jul 13, 2009 at 19:02 UTC | |
|
Re: Help with 'use Warnings' please?
by JavaFan (Canon) on Jul 13, 2009 at 15:55 UTC | |
by wa4otj (Beadle) on Jul 13, 2009 at 17:22 UTC | |
by JavaFan (Canon) on Jul 13, 2009 at 17:56 UTC | |
by wa4otj (Beadle) on Jul 13, 2009 at 18:50 UTC |