I suspect you're having trouble with closures{ my $Aspirin = sub { return $wiz->_text_frame( { -title => 'Partitioning', -boxedtext => "/mirror/inifiles/partition.$oschoice", } ); }; $wiz->addPage($Aspirin); }
In my original program, this unnamed subroutine, this anonymous subroutine, whose reference is now stored in $Aspirin, refers to two variables outside its scope. Namely $oschoice and $wiz, which are not declared (my) within $Aspirin. This makes $Aspirin a closure.
Each time you call this subroutine, $Aspirin->(); it calls _text_frame with the current value of $oschoice
So if $oschoice="Lin" then $Aspirin->() returns a frame with /mirror/inifiles/partition.Lin
Next you change $oschoice="Win" and then $Aspirin->() returns a frame with /mirror/inifiles/partition.Win
The first step in the wizard edits $oschoice, then when you click next, the wizard invokes $Aspirin , which returns a new frame using the current value of $oschoice
If you click the back button and select a different OS, and click next again, the wizard will call $Aspirin again
More on closures, hopefully easier to understand :) oh and no wizards or witches :)
In reply to Re^3: Confused by variable scope in Tk::Wizard
by Anonymous Monk
in thread Confused by variable scope in Tk::Wizard
by rgcosma
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |