Somu wrote: > Actually, that was just an example to explain my problem. I am facing > this problem when i use Tk. Any subroutine associated with the > -command option of a button widget. > > use Tk; > my $mw = MainWindow->new; > my $b = $mw->Button(-text=>'hello',-command=>sub { &welcome })->pack; > my $l = $mw->Label(-text=>'')->pack; > sub welcome { > $l->configure(-text=>'welcome buddy'); } > MainLoop; > > in the above example, i have to add a declaration > sub welcome; > before declaring $b, but cant define it.
Change: my $b = $mw->Button(-text=>'hello',-command=>sub { &welcome })->pack; To: my $b = $mw->Button(-text=>'hello',-command=>sub { welcome() })->pack; John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/