>>>>> "Somu" == Somu  <[EMAIL PROTECTED]> writes:

Somu> Actually, that was just an example to explain my problem. I am facing
Somu> this problem when i use Tk. Any subroutine associated with the
Somu> -command option of a button widget.

Somu> use Tk;
Somu> my $mw = MainWindow->new;
Somu> my $b = $mw->Button(-text=>'hello',-command=>sub { &welcome })->pack;
Somu> my $l = $mw->Label(-text=>'')->pack;
Somu> sub welcome {
Somu> $l->configure(-text=>'welcome buddy'); }
Somu> MainLoop;

Somu> in the above example, i have to add a declaration
Somu> sub welcome;
Somu> before declaring $b, but cant define it.

Just a guess, but could you try changing that to -command => \&welcome ?
There's no need to make a closure to hold a global that doesn't yet exist,
when the coderef is a perfectly valid coderef. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to