Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Perl/Tk command execution weirdness

by autark (Friar)
on Dec 11, 2000 at 23:00 UTC ( [id://46116]=note: print w/replies, xml ) Need Help??


in reply to Perl/Tk command execution weirdness

The reason is actually quite obvious once you see why. When you use an anonymous array to create the callback for your button, you create it once and only once. That means that the array will contain f.exs: [CODE(0x80e4ec), ''] The empty string ('') probably would be the output of $directory->get() at the start of the program, so that is what you send to the function.

Now, when you use an anonymous function, and within it use the code to fetch the output from the Entry widget, it will be called every time. Thus - $directory->get() will be called each time you press the button. This is in contast to the anonymous array, where the get() function only will be called once - when you create the array.

Autark.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://46116]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2024-04-19 15:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found