Hi All,

Here is the message I got after using "use warnings;" and "use
diagnostics;".

Variable "$number" will not stay shared at x.pl line 36 (#1)
    (W closure) An inner (nested) named subroutine is referencing a
    lexical variable defined in an outer subroutine.

    When the inner subroutine is called, it will probably see the value of
    the outer subroutine's variable as it was before and during the *first*
    call to the outer subroutine; in this case, after the first call to the
    outer subroutine is complete, the inner and outer subroutines will no
    longer share a common value for the variable.  In other words, the
    variable will no longer be shared.

    Furthermore, if the outer subroutine is anonymous and references a
    lexical variable outside itself, then the outer and inner subroutines
    will never share the given variable.

    This problem can usually be solved by making the inner subroutine
    anonymous, using the sub {} syntax.  When inner anonymous subs that
    reference variables in outer subroutines are called or referenced, they
    are automatically rebound to the current values of such variables.

Variable "$flag" will not stay shared at x.pl line 40 (#1)
Variable "%t" will not stay shared at x.pl line 48 (#1)

Apparently, I dont understand the above and what it meant. It appears that
the variables inside the subroutine is being reused or wrongly used. because
i
am now getting this error:

Tk::Error: Can't call method "configure" on an undefined value at x.pl line
48.
 Tk callback for .toplevel.frame.button5
 Tk::__ANON__ at C:/Perl/lib/Tk.pm line 252
 Tk::Button::butUp at C:/Perl/lib/Tk/Button.pm line 111
 <ButtonRelease-1>
 (command bound to event)

Line 48 is referring to:
$t{LZ}->configure(-text=>$number);

1st time it runs, no problem; 2nd time it gave that error as if the variable
$t{LZ} does not exists.


Any idea where i am doing wrong?

BTW. I cannot use withdraw/iconfy because the Keypress event will be used on
another
TopLevel and thus i have to destroy this toplevel everytime it leaves.

Dan



On Wed, Sep 2, 2009 at 11:13 PM, Brian Raven <bra...@nyx.com> wrote:

> From: perl-win32-users-boun...@listserv.activestate.com
> [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
> Daniel Burgaud
> Sent: 02 September 2009 15:27
> To: Perl-Win32-Users
> Subject: need help with Tk: I could not figure the error
>
> > I have this test script below.
> >
> > A toplevel containing a button that invokes another toplevel.
> > The first time I invoke this second window, all works fine and returns
> properly without error.
> >
> > however, when I reenter again (clicking on "Get Number" button) I get
> this error message.
> >
> > Tk::Error: not a Tk object
> >  Tk::die_with_trace at x.pl line 46
> >  main::AddNumber at x.pl line 66
> >  main::__ANON__ at C:/Perl/lib/Tk.pm line 252
> >  (eval) at C:/Perl/lib/Tk.pm line 252
> >  Tk::__ANON__ at C:/Perl/lib/Tk/Button.pm line 111
> >  Tk::Button::butUp at x.pl line 79
> >  (eval) at x.pl line 79
> >  main::GetNumber at x.pl line 17
> >  main::__ANON__ at C:/Perl/lib/Tk.pm line 252
> >  (eval) at C:/Perl/lib/Tk.pm line 252
> >  Tk::__ANON__ at C:/Perl/lib/Tk/Button.pm line 111
> >  Tk::Button::butUp at x.pl line 20
> >  (eval) at x.pl line 20
> >  Tk callback for .toplevel.frame.button5
> >  Tk::__ANON__ at C:/Perl/lib/Tk.pm line 252
> >  Tk::Button::butUp at C:/Perl/lib/Tk/Button.pm line 111
> >  <ButtonRelease-1>
> >  (command bound to event)
> >
> > Hoping for help.
> >
> > thanks.
> > Dan
> >
> >
> >
> >
> ########################################################################
> ####################
> > use strict;
>
> perl will give you a clue if you add "use warnings;" here. It will even
> give some advice if you make it "use diagnostics;".
>
> > use Tk;
> > ...
>
> HTH
>
> --
> Brian Raven
> This e-mail may contain confidential and/or privileged information. If you
> are not the intended recipient or have received this e-mail in error, please
> advise the sender immediately by reply e-mail and delete this message and
> any attachments without retaining a copy.
>
> Any unauthorised copying, disclosure or distribution of the material in
> this e-mail is strictly forbidden.
>
> _______________________________________________
> Perl-Win32-Users mailing list
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to