Here is the exact same thing only written more verbosely
{ my $Aspirin = sub { return $wiz->_text_frame( { -title => 'Partitioning', -boxedtext => "/mirror/inifiles/partition.$oschoice", } ); }; $wiz->addPage($Aspirin); }
I suspect you're having trouble with closures

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.