I was looking at the source code for Tk::OptionMenu version 4.013, and I just can't get my brain wrapped around this little bit of logic in addOptions().
Here's a snippet:
sub addOptions
{
my $w = shift;
my $menu = $w->menu;
my $tvar = $w->cget(-textvariable);
my $vvar = $w->cget(-variable);
my $oldt = $$tvar;
my $width = $w->cget('-width');
my %hash;
my $first;
while (@_)
{
my $val = shift;
my $label = $val;
if (ref $val)
{
if ($vvar == $tvar)
{
my $new = $label;
$w->configure(-textvariable => ($tvar = \$new));
}
($label, $val) = @$val;
}
my $len = length($label);
[snip]
Okay, so if I pass it an array ref, and if my $tvar == $vvar, then I assign $new the value of my label (but... $label is $val is a ref...) and then I take a ref of $new (yielding a ref of an array ref...) and assign it to $tvar and configure my textvariable with it.
Do I have that right?
I'm almost certain that this code was supposed to be structured like this:
($label, $val) = @$val;
if ($vvar == $tvar)
{
my $new = $label;
$w->configure(-textvariable => ($tvar = \$new));
}
If lots of people agree, I'd be happy to email the author but... I can't find the author for this module. Maybe I just don't know where to look. If you agree that the above code has a bug and can provide an email address for the author, I'd greatly appreciate it.
Thanks!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.