Most Honorables,
I am running into an interesting challenge that I hope your glowing wit will lighten. I have an Entry widget in which my user can only enter the letters DATSOU. The program allows the user to keep some default that can be loaded. When my user saves default from that widget, I pick up the textvariable (he cannot type any other letters than DATSOU)and place it in my default file (everything is fine here). When the user loads the default from the file, I read the file in an array an assign the values with the corresponding variables. However, I get this error:
"Use of uninitialized value in string eq at file.pl line 200, <DEFAULTIN> line 21."
I have other entry widgets where I have restricted my user in other ways, like can type only numerical value, or only characters and those work just great.
Enough chatting, here is my code:
#!/usr/bin/perl -w
use strict;
use Tk;
use Tk::Entry;
my @arraydefault;
my $copytf;
$copytf = $page2 ->Entry (-textvariable=> \$copyentry,
-validate=> 'key',
-validatecommand=> sub{$_[1] =~/['a','d', 't', 's', 'o', '
+u', 'A','D', 'T', 'S', 'O', 'U']/},
-invalidcommand=> sub{$page2->bell})->pack;
my $loaddefaultb=>$mw->Button (-text=>'Load Defaults', -command => sub
+ {loaddef()})->pack;
MainLoop;
sub loaddef(){
open (DEFAULTIN, "<default.txt");
while(<DEFAULTIN>){
chomp;
@arraydefault = split /,/;
}#while
$copyentry=$arraydefault[11];}
Thanks in advance for your precious time,
Looking foward to your replies,
Claire
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.