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;

In reply to Problem with hash by padawan_linuxero

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.