in reply to Perl/Tk command execution weirdness
autark is correct. So I'd write this as:
(someone asked me about that).my $newBtn= $upper->Button( '-text' => "New Subdirectory", '-command' => sub { newDir( $direntry->get() ) }, )->grid( '-column' => 1, '-row' => 1 );
Also note that current versions of Perl don't ever free anonymous subroutines (because of a reference loop in how they are tracked) so if you replace that button or its action, you now leak memory. (I have a neat Tk app that leaks memory like fishnet because I'm constantly replacing buttons/actions as the state of things change.)
- tye (but my friends call me "Tye")
|
|---|