What do these Perl / Tk errors from Tk :: After mean?

Here are the errors:

$ perl ftper.pl
Use of uninitialized value $ id in hash element at /usr/lib/perl5/vendor_perl/5.1
/i686-cygwin/Tk/After.pm line 39.
se of uninitialized value $ id in hash element at /usr/lib/perl5/vendor_perl/5.1
/i686-cygwin/Tk/After.pm line 39.
se of uninitialized value $ id in hash element at /usr/lib/perl5/vendor_perl/5.1
/i686-cygwin/Tk/After.pm line 39.
se of uninitialized value $ id in hash element at /usr/lib/perl5/vendor_perl/5.1
/i686-cygwin/Tk/After.pm line 39.
se of uninitialized value $ id in hash element at /usr/lib/perl5/vendor_perl/5.1
/i686-cygwin/Tk/After.pm line 39.
se of uninitialized value $ id in hash element at /usr/lib/perl5/vendor_perl/5.1
/i686-cygwin/Tk/After.pm line 39.
se of uninitialized value $ id in delete at /usr/lib/perl5/vendor_perl/5.10/i686
cygwin / Tk / After.pm line 87.
se of uninitialized value $ id in delete at /usr/lib/perl5/vendor_perl/5.10/i686
cygwin / Tk / After.pm line 87.
se of uninitialized value $ id in delete at /usr/lib/perl5/vendor_perl/5.10/i686
cygwin / Tk / After.pm line 87.
se of uninitialized value $ id in delete at /usr/lib/perl5/vendor_perl/5.10/i686
cygwin / Tk / After.pm line 87.
se of uninitialized value $ id in delete at /usr/lib/perl5/vendor_perl/5.10/i686
cygwin / Tk / After.pm line 87.
se of uninitialized value $ id in delete at /usr/lib/perl5/vendor_perl/5.10/i686
cygwin / Tk / After.pm line 87.  

Here is the Perl / Tk code:

#! /usr/bin/perl -w

use strict;
use Tk;
use Tk::Scale;
use File::DosGlob 'glob';


#####################################################################
# Define variables                              #
#####################################################################
my $UserID;
my $Password;
my $BnsNode;
my $Status_msg = "BUILD SCRIPT!";

#####################################################################
# Window variables                          #
#####################################################################
my $mw;
my $frmUserID;
my $lblUserID;
my $frmPassword;
my $lblPassword;
my $edtUserID;
my $edtPassword;
my $frmTop;
my $frmBig;
my $frmButtonLine;
my $btnExit;
my $btnSubmit;
my $lblStatus;
my $lblUnixNode;
my $frmUnixNode;
my $edtUnixNode;

#################################################################
# Main Logic                            #
#################################################################
init_mainwindow();
MainLoop;



#################################################################
# init_mainwindow                       #
#################################################################
sub init_mainwindow {
    $mw = MainWindow->new;
    $mw->title("BUILD");
    $mw->resizable(100, 100);
    $mw->geometry("+175+100");

    # Top Level frame for top section of form.
    $frmTop = $mw->Frame(-bd => 2, -relief => 'ridge')
        ->pack(-side => 'top', -fill => 'x', -pady => 3);


    $frmUserID = $frmTop->Frame(-bd => 2)->pack(
        -side => 'top', -fill => 'x');
    $lblUserID = $frmUserID->Label(-text => "Unix User ID:")
        ->pack(-side => 'left');
    $edtUserID = $frmUserID->Entry(-textvariable => \$UserID,
        -background => 'white')->pack(-side => 'left');


    $frmUnixNode = $frmTop->Frame(-bd => 2)->pack(
    -side => 'top', -fill => 'x');
    $lblUnixNode = $frmUserID->Label(-text => "BNS Number")
        ->pack(-side => 'left');
    $edtUnixNode = $frmUserID->Entry(-textvariable => \$BnsNode,
    -background => 'white')->pack(-side => 'left');


$frmPassword = $frmTop->Frame(-bd => 2)->pack(
    -side => 'top', -fill => 'x');
$lblPassword = $frmPassword->Label(
    -text => "Password:    ")->pack(-side => 'left');
$edtPassword = $frmPassword->Entry(-textvariable => \$Password,
    -background => 'white', -show => "*")
    ->pack(-side => 'left');



# Top Level frame for bottom section of form.
$frmButtonLine = $mw->Frame(-bd => 2, -relief => 'ridge')
    ->pack(-side => 'top', -fill => 'x', -pady => 3);
    $btnExit = $frmButtonLine->Button(-text => "Exit", 
        -command => \&close_mw, -width => 6)->pack(
        -side => 'right', -padx => 1);
        $btnSubmit = $frmButtonLine->Button(-text => "Run Script", 
    -command => \&execute_script, -width => 6)->pack(
        -side => 'right', -padx => 1);
    $lblStatus = $mw->Label(-textvariable => \$Status_msg,
        -borderwidth => 2, -relief => 'groove')
        ->pack(-fill => 'x', -side => 'bottom');

    $edtUserID->focus;

}


#####################################################################
# excute_script                             #
#####################################################################
sub execute_script {
    unless (defined($UserID)) {
        update_status("Must enter a user id!");
        $edtUserID->focus;
        return 0;
    }
    unless (defined($Password)) {
        update_status("Must enter a password!");
        $edtPassword->focus;
        return 0;
    }

    update_status("$BnsNode ,$UserID ");
}

#####################################################################
# close_mw                              #
#####################################################################
sub close_mw {
    $mw->destroy;
}


#####################################################################
# update_status                             #
#####################################################################
sub update_status {
    my ($msg) = @_;

    $Status_msg = $msg;
    $lblStatus -> update;
}
+3
source share
6 answers

The error messages are quite simple:

Using the uninitialized value of $ id in the hash element in ... Tk / After.pm line 39.

Using the uninitialized value of $ id in delete at ... Tk / After.pm line 87.

  • " " , undef (undefined).
  • $id - .
  • " -" , -, . $h{$id}
  • "in delete" , -, . delete $h{$id}
  • "... Tx/After.pm" - , .
  • " 39" " 87" - ( ), .

Tk:: After Perl/Tk. , " ( ) 500 ". $id - .

. Tk:: After , . , Tk, . Perl 5.10 Tk 804.028.

+4

, , . , , rukus:

use Carp;
$SIG{__WARN__} = sub { &Carp::cluck }
+6

script, , , -w shebang, use warnings;, . . Perl pragma? .

: , .

+2

- , , Strawberry Perl 5.10. , , ( , - , $id , $id ).

+2

v5.10.0 804.028-1 x86 Cygwin. , , , , //??? .

I suspect that the PerlTk source code is correct and that the problem is with the Perl source / executable itself - to whom should this be reported?

Mikep

+1
source

I get the same error. I believe this is because there is no display server. A simpler test is to simply type a “widget” at the Cygwin prompt. This should lead to a demonstration of the Tk widget. I will send a report if I find anything else.

+1
source

All Articles