I have been working on my pet project and with the help of some monks my project is continue to grow, at last I have a program that actually does what I want, but always a but, is marking me an error everytime it runs, the error is these one
:Use of uninitialized value in hash element at test5.pl line 49.
I have been reading about the hash and to me the program makes sense to what Ellie Quigley said on the book
can someone see the problem?
this is the code:
#!/usr/bin/perl -w
use warnings;
use strict;
use Tk;
my @banklist = qw(Banamex HSBC Santander Banorte);
my $mw = MainWindow->new();
my %data;
foreach my $bank (@banklist) {
$data{$bank}{'frame'} = $mw->Frame->pack(-fill=>'x');
$data{$bank}{'bankname'} = $bank;
$data{$bank}{'status'} = 'offline';
$data{$bank}{'label'} = $data{$bank}{'frame'}->Label(
-textvariable => \$data{$bank}{'bankname'})->pack(-side=>'left');
$data{$bank}{'entry'} = $data{$bank}{'frame'}->Entry(
-textvariable => \$data{$bank}{'status'},
-bg => 'white',
)->pack(-side=>'right');
}
$mw->repeat(10000, \&CheckForActiveBanks);
sub CheckForActiveBanks
{
my %statusList = ();
#-- Reset the list of bank statuses.
#
foreach my $bank (@banklist) {
$statusList{$bank} = 'X';
}
#-- Read in the data file.
#
open (DAT, "santa1.txt") || die ("No se pudo abrir el archivo");
my @lines = <DAT>;
close(DAT);
#-- Set the status for each bank found in the data file.
#
foreach my $lineas (@lines) {
chomp $lineas;
my $statuss;
my $banco;
($banco, $statuss) = split(/\|/, $lineas);
$statusList{$banco} = $statuss;
}
#-- Update the data for the list of banks.
#
foreach my $bank (@banklist) {
if ($statusList{$bank} eq "ACTIVO") {
$data{$bank}{'entry'}->configure(-fg => 'green');
$data{$bank}{'status'} = 'online';
}
else {
$data{$bank}{'entry'}->configure(-fg => 'red');
$data{$bank}{'status'} = 'offline';
}
}
}
MainLoop;