???

#!/usr/bin/perl -- use strict; use warnings; use Tk; use Tk::BrowseEntry; my %foo = ( man => [ 'a'..'c' ], manl => "man label", manv => "", choo => [ 66 .. 69 ], chool => "choo label", choov => "", ); my $mw = tkinit; $mw->BrowseEntry( -choices => $foo{man}, -label => $foo{manl}, -variable => \$foo{manv}, )->pack; $mw->BrowseEntry( -choices => $foo{choo}, -label => $foo{chool}, -variable => \$foo{choov}, )->pack; $mw->MainLoop; use Data::Dump; dd \%foo; __END__ { choo => [66 .. 69], chool => "choo label", choov => 68, man => ["a", "b", "c"], manl => "man label", manv => "b", }

#!/usr/bin/perl -- use strict; use warnings; use Tk; use Tk::BrowseEntry; my $mw = tkinit; my @barvar; for my $ix ( 'A'..'C' ){ my @var = ( "", undef ); my $widget = foomanchoo( $mw, { choices => [ map { $ix.' '.$_ } 1 .. 12 ], label => "$ix label ", variable => \$var[0], } ); $var[1] = $widget; push @barvar, \@var; } $mw->MainLoop; use Data::Dump; dd \@barvar; sub foomanchoo { my ( $mw, $foo ) = @_; my $bro = $mw->BrowseEntry( -choices => $$foo{choices}, -label => $$foo{label}, -variable => $$foo{variable}, ); $bro->pack; $bro; } __END__ [ [ "A 2", bless({ _BE_buttonHack => 1, _BE_curIndex => 1, _BE_popped => 0, _BE_Style => "MSWin32", _TkValue_ => ".browseentry", }, "Tk::BrowseEntry"), ], [ "B 6", bless({ _BE_buttonHack => 1, _BE_curIndex => 5, _BE_popped => 0, _BE_Style => "MSWin32", _TkValue_ => ".browseentry1", }, "Tk::BrowseEntry"), ], [ "C 4", bless({ _BE_buttonHack => 1, _BE_curIndex => 3, _BE_popped => 0, _BE_Style => "MSWin32", _TkValue_ => ".browseentry2", }, "Tk::BrowseEntry"), ], ]

References quick reference, Data::Diver, Lexical scoping like a fox, Variable Scoping in Perl: the basics, ...


In reply to Re: data structure problem by Anonymous Monk
in thread data structure problem by perltux

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.