goonarific has asked for the wisdom of the Perl Monks concerning the following question:
the if statement just makes sure that the user belongs to a certain office before it gets put into the hash. the hash is wo_usr_proj, and I want to use @usr_list for the hash value. when I check what @usr_list is set to after line 6 I see that its just an empty array, so when I push something on to it, I'm getting a two item array. this is true through out the whole execution of the code, not just on the first step. Also, shouldn't it be a single item array after the push since the initial array was empty. I'm getting an empty slot and then the username when I print out the array. Any ideas on what I'm doing wrong? thanks in advance.1. foreach (@ufile_contents) 2. { 3. ($buser2,$email,$project) = split(/\|/,$_); 4. if($uo_hash{lc($buser2)} =~ /WO/) 5. { 6. @usr_list = $wo_usr_proj{$project}; 7. push(@usr_list,$buser2); 8. $wo_usr_proj{$project} = @usr_list; 9. } 10. }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: dealing with arrays as hash values
by Zaxo (Archbishop) on May 17, 2004 at 19:56 UTC | |
by goonarific (Initiate) on May 17, 2004 at 21:01 UTC | |
by sacked (Hermit) on May 17, 2004 at 22:46 UTC |