--- James Edward Gray II <[EMAIL PROTECTED]>
wrote:
> On Mar 8, 2004, at 1:24 PM, Stuart White wrote:
> 
> > If I had a hash, I'd have to have a key and a
> value
> > though.  I'm just looking for one or the other.  I
> > suppose I could have key value pairs in the %SAN
> hash
> > like so:
> 
> Perl hashes are pretty versatile.  As Wags was
> saying, just stick each 
> item in the hash under the unique key you want.  The
> value doesn't 
> matter at all.  In the end, pull the keys and boom,
> problem solved.  
> Let's look at an example:
> 
> my @words = qw(dog cat dog lizard dog wombat dog);
> my %seen;
> foreach (@words) {
>       $seen{$_}++;
> }
> my @words = keys %seen;
> print "@words\n";             # only prints one dog
> 
> Hope that helps.
> 
Conceptually, what you say the result is, is what I
want, thanks.  When I read it though, without the
comment, I'd guess that the program would pair those
words like so:
dog:cat, dog:lizard, dog:wombat
with dog:lizard overwriting dog:cat, and dog:wombat
overwriting dog:lizard.
I seem to remember an example like this from the Llama
book.

However, absent my confusion, and given you're
correct, would this:
foreach (@words) {
>       $seen{$_}++;
produce values at all to pair with the keys?  I know
the value of the value doesn't matter, what I wrote as
Parker:san before could just as well been
Parker:valuePlaceHolder.  but absent assgning a value,
is a number just assigned?  This is the other bit of
my confusion.
Thanks.


__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com

-- 
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