I am new to Perl and even newer to Tk. I'm trying to write a login dialog box for a database and learning along the way. I get unexpected behaviour in the following script ...
#/usr/bin/perl use warnings; use strict; use Tk; use Tk 800.000; use Tk::Dialog; my $user = "Hello"; my $password = "World"; my $mw = MainWindow->new(); my $dlgLDL = $mw->Dialog( -title=>'Login', -buttons=>['Ok','Cancel'], -default_button=>'Ok'); my ($fLeft,$fRight) = map {$dlgLDL->Frame(-padx=>4,-borderwidth=>0,-relief=>'groove')- +>pack(-side=>$_,-pady=>5)} qw/left left/; my ($l1,$l2) = map {$fLeft->Label( -text => $_, -anchor=>'e', -width=>12)->pack +(-side=>'top',-pady=>3)} qw/User: Password: /; my ($dfHost, $dfPort, $dfUser,$dfPassword) = map {$fRight->Entry( -textvariable=>$_ )->pack(-side=>'top',- +pady=>3)} qw/\$user \$password/; my $selected = $dlgLDL->Show(); MainLoop;
The -textvariable substitution in the third map statement above doesn't do what I hoped, i.e., set up the link to the associated variable. Instead it seems to just place the quoted text into the Entry field. What am I missing?

Please note this may be a very simple mistake as I am still trying to pick up basic Perl syntax.


In reply to Tk with map - Perl newbie by stickleback

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.