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.