in reply to dealing with arrays as hash values
You're not that far off, I think your code would work if you replaced line 8 with $wo_usr_proj{$project} = \@usr_list; - hash values must be scalars, so a reference is needed.
Your code can be cleaned up a bit. You can read data directly from the file, for (<INFH>) { Loop variables are better as lexicals, and split uses $_ as the default second argument, my ($user, undef, $project) = split /\|/; The remainder can be condensed to a conditional push onto the dereferenced array in the hash,
push @{$wo_usr_proj{$project}}, $user if $uo_hash{lc($user)} =~ /WO/; }
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: dealing with arrays as hash values
by goonarific (Initiate) on May 17, 2004 at 21:01 UTC | |
by sacked (Hermit) on May 17, 2004 at 22:46 UTC |