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.

James


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