Thanks for the reply eventhough my question was not
clear.

Let me explain what I am trying to do.

I have a hash named %orgjobs whose keys have multiple
values.  The keys are department numbers and the
values are job_titles.  There is a also a text file
that has a list of departments, users, and the users'
job titles.  I want a report that shows the
departments and the job titles in that department. 
For example:
Dept 100: Engineer, Scientist
Dept 200: Programmer, Manager
Dept 300: Secretary, Student

A dept 100, for example, can have more than one
engineer and more than one scientist.  However, the
report just need to show one.

So this is what I did in perl....

$found = 0;
foreach $job (@{$orgjobs{$dept}}) {
   if ($job eq $job_title) {
       $found++;
   }
}
if ($found == 0) {
    push(@{$orgjobs{$dept}},$job_title);
}

The variable job_title is assigned earlier in the code
and contains a the name of a job title.  I am using a
while loop to iterate through the text file.

My question is:
Is there another way to find out if a particular value
already exists as a value for a key when the key has
multiple values? I know it sounds confusing.....

--- Casey West <[EMAIL PROTECTED]> wrote:
> On Tue, Aug 07, 2001 at 12:14:55PM -0700, Sophia
> Corwell wrote:
> : Hello Perl Help,
> : 
> : Does anyone have any ideas on what is a good way
> to
> : check the existance of a value for a key that has
> : multiple values?
> 
> I'm not quite sure what you're asking for so I'm
> going to try and
> rephrase your question, then answer that one.  :-)
> 
> Question:  I have a key in my hash that could have
> several valid
>   values.  For instance, $hash{key} could return
> "foo" and "bar" and
>   my program would be ok with that.  What is the
> best way to figure
>   out what value $hash{key} has?
> 
> I hope that I got the question sorted out right in
> my head.  The
> answer I would give to that question is, use an if
> statement:
> 
>   if ( $hash{key} eq 'foo' ) {
>     # do stuff based on 'foo' here
>   } elsif ( $hash{key} eq 'bar' ) {
>     # do stuff based on 'bar' here
>   } else {
>     # we should probably throw an error here because
> there are no
>     # valid values of $hash{key} left
>   }
> 
> If I got this wrong, and it's very possible, try and
> set me straight
> so we ( the list ) can help you better.
> 
> Thanks,
> 
>   Casey West
> 
> -- 
> Disclaimer - These opiini^H^H geez! ^H^H ^Q ^[ ....
> :w :q :wq :wq! ^d
> X ^? exit X Q ^C ^? :quitbye CtrlAltDel ~~q :~q
> logout save/quit
> :!QUIT ^[zz ^[ZZZZZZ ^H man vi ^ ^L ^[c ^# ^E ^X ^I
> ^T ? help helpquit
> ^D ^d man help ^C ^c help ?Quit ?q CtrlShftDel"Hey,
> what does this
> button d... -- Seen in a .signature file


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to