[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] re-initializing associative arrays



>Hello.  I was under the impression that after
>
>          $a{1} = "peter";
>          undef @a;
>
>$a{1} would have no value.  Apparently that isn't the case because $a{1}
>is still equal to "peter".
>
>Can someone tell me what is the most efficient way of re-initializing an
>array?
>
>Thanks in advance.  - peter


The problem here is that you're not undef'ing the hash you made. By using
curly brackets {}, you're making a hash- a set of variables linked with
keys. It's addressed with the symbol %. So if you wanted that script to
work, it could be done in two ways-

$a[0] = "peter";
undef @a;

$a{'1'} = "peter";
undef %a;

- Strider



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch