in reply to Passing arrays and references to arrays
You're exactly right in your analysis of what is going on and I'd consider that a serious bug in the documentation of the module. It actually gets worse when you see the rest of that code sample:
my @choices = [ qw/one one.green one.blue one.yellow two.blue two.green two.cyan three.red three.white three.yellow/ ]; $mw->Button->pack(-side => 'left'); my $me = $mw->MatchEntry( -choices => @choices, -fixedwidth => 1, -ignorecase => 1, -maxheight => 5, -entercmd => sub { print "callback: -entercmd\n"; }, -onecmd => sub { print "callback: -onecmd \n"; }, -tabcmd => sub { print "callback: -tabcmd \n"; }, -zerocmd => sub { print "callback: -zerocmd \n"; }, )->pack(-side => 'left', -padx => 50);
Now consider what happens if @choices contains more than one element (as you'd expect to be able to do with an array). It gets particularly bad if the array has an even number of elements - all of the following parameters will be broken.
I recommend you raise a bug on rt.cpan.org and, in the meantime, make a note of the problem on AnnoCPAN.
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Passing arrays and references to arrays
by GrandFather (Saint) on Aug 10, 2005 at 20:39 UTC |