Charlotte Hee wrote:

>
> For a single record I can see how that works but let's say I have
> 4 or 5 employees and I have the employee information for each one
> (assumed). Now I want to build a record for each employee in a loop like
> this:
>
>   @names = ('Jason','Aria','Samir','Owen');
>
>   foreach $na ( @names ) {

So all the records differ only in name, and all other parameters stay the same?

>     $record = {
>       NAME   => $na,
>       EMPNO  => $emp_no,
>       TITLE  => $title,
>       AGE    => $age,
>       SALARY => $salary,
>       PALS   => [ $friend_list ],
>     };
>
> # store record
>  $byname{ $record->{NAME} } = $record;
>
>  }
>
> Now I want to add something later, after the record for the employee has
> been created. For example, I want to add the phone for Owen.
> When I try the following I get "can't use undefined value...".

Since you don't seem to be showing us the code you are actually using, we are
somewhat at a disadvantage.  ONe thing you should not, though.  Since the nested
hashes should be storedonly by reference, you should use the derefereing operator
-> to get at least the fianl element.

>  $byname{ Owen }{ PHONE } = '999-9999';

Should be:
$byname{ Owen }->{ PHONE } = '999-9999';
are you using strict?  The code above should cause an error, not just an
uninitialized variable warning.  You really should put:
use strict;
use warnings;
at the top of the script, and clean up the errors returned before you try to take
on multidimensional structure problems.  Houses built on sand cannot be expected
to stand.

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to