There's more than one way to do things | |
PerlMonks |
Re: Perl/Tk parametersby stephen (Priest) |
on Apr 15, 2002 at 17:06 UTC ( [id://159268]=note: print w/replies, xml ) | Need Help?? |
Actually, the problem has nothing to do with Tk per se. What you're trying to do is pass Tk a reference to a subroutine to call later on. Unfortunately, you're trying to pass arguments at the same time, which means that Perl thinks you're telling it to call the subroutine immediately at runtime and pass to Tk a reference to what the subroutine returns. So if I did this:
To get a reference to a subroutine that will call queryDB with the right parameters when you click the button, do this:
When you say sub { ... } without naming the subroutine, perl creates an anonymous subroutine and returns the reference. See perlman:perlref and perlman:perlsub for more information. stephen Update: Added additional explanaton.
In Section
Seekers of Perl Wisdom
|
|