I'm probably going to mess this up, but I think what's happening is:

You use \$map_fields[$cnt2] to store the location of (pointer to) the space occupied by $map_fields[$cnt2], but I think that the dereferencing of the array is happening first, so you store a reference to a string which is the value stored at $map_fields[$cnt2].

I think the solution is to initially store references to scalars in @map_fields, then always manipulate them as references, as in:
use Tk; $mw = new MainWindow(-title=>'mapp'); $pg = $mw->Frame; @map_fields = \(qw( A B C D E )); $cnt2 = 0; @file_fieldnames = qw( SHOW COLUMNS FROM lead SKIP ); foreach my $field ( @file_fieldnames ) { $pg->Label(-relief => 'sunken', -width => 15, -text => $field)->pac +k(); my $brb = $pg->BrowseEntry(-variable => ($map_fields[$cnt2]) ); $brb->insert('end', @$dbfields); $cnt2++; $brb->pack(); } my $btn =$pg->Button(-text=>'doit', -command => sub { doit() } ); $btn->pack; $pg->pack(); MainLoop; sub doit { $ifg->{parameter} = '1,2,3,4,5'; my @a = ( split ( ",", $ifg->{parameter} ) ); for ( @map_fields ) { $$_ = shift @a } ; }
This code seems to do what you want, though I didn't learn the grid placment manager or make a DB to truly try it out.

--Bob Niederman, http://bob-n.com

All code given here is UNTESTED unless otherwise stated.


In reply to Re: Updating variables in Tk programmes by bobn
in thread Updating variables in Tk programmes by jdtoronto

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.