in reply to Re: Re (tilly) 1: associative array problem
in thread associative array problem
As for the problem you complained about, I already told you why you have the behaviour you do, and how to automatically catch the error that leads to it. And what I meant by saying that you're using an array instead of a hash is that you are using strings like '01' as indexes into an array. I strongly recommend either making that a hash, or just using numbers. As it stands your choice of index and data structure are passing conflicting messages. Experienced programmers see conflicts like that and label them as mistakes. What kind of mistake may not be obvious, but they are mistakes.
UPDATE
BTW you may find it better to just use a nested hash.
For instance if you just assign your values like:
without initializing $STUDQT{'32000012'}{mname}, Perl will no longer misbehave on you. (Of course strict.pm is still strongly recommended to catch other incidences of the same mistake. Catching bugs early is a Good Thing.)$STUDQT{'32000012'}{mname}[1] = 0;
|
|---|