> Hi, perl-friends,
>
> Here's the setup:
> I have set up a hash %categories where the key is one number
> and the value
> is another
> i.e. $categories('1094') = 100049-0220-100004
do you mean $catagories{'1094'} ?
>
> So, further on down, I'm trying to do a lookup in %categories
> to see if a
> value is there. (I can
if(exists $catagories{$ccid}) { .... }
You can do that anywhere after the hash is created and it will work peachy!
As far as the while not stopping why not try a foreach
foreach $k(keys %catagories) { .... }
> swap the key and the value in the setup if it will make this
> next step
> easier....)
> and I had a while loop to search through each of the keys &
> values, but the
> problem is
> that it doesn't break out of the while loop, and the wrong
> value gets set
> as $myID;
>
> $ccid = 1094;
>
> ## Attempt #2
> ### 1.22.03 change to try to get it to stop once it finds
> ### the correct value.
> #until ($value == $ccid)
> # {
> # ($key, $value) = each %categories;
> # }
>
> ## Attempt #1
> #while(my ($key, $value) = each %categories )
> #{
> #print "CC ID: $ccid: Key : $key : Value: $value\n";
> # if ($value == $ccid)
> # {
> # $myID = $key;
> #} ## Need to break out of the while loop here once find it.
> #}
>
> print "My ID is $categories{$ccid}\n"; ## Returns a null
>
> Unfortunately, in all the documentation, it shows using an
> HTG value in the hash ($categories('1094')), and I only have
> a variable to access. I looked into mapping, but got my head
> wrapped around the axel.
>
> So, here's the question:
> Where can I find information on how to use variables as the
> keys in a hash?
>
> Thanks,
> Lara
> ---------------------
> Lara J. Fabans
> Lodestone Software, Inc
> [EMAIL PROTECTED]
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]