Stuart White wrote: > I'm reading in lines of text, and extracting the > relevant parts of it. These relevant parts are then > being pushed onto an array. My trouble is that these > parts are a maximum of 24 unique names. However, when > pushed onto the array, there is no mechanism for > comparison where the repeated names are skipped. I'm > not sure how to do it. Here's the code I have: > > while (<STATS>) > { > if ($_ =~ /\[($team)\] ($player)/) > { > if ($1 eq "SAN") > { > push (@SAN, $2); > #unless ($2 eq $SAN[i]) #I need a foreach loop here > #that will give the unless a $SAN[i] to compare > #against the $2, I'm just not sure how to write it. > } > > elsif ($1 eq "PHX") > { > push (@PHX, $2); > } > > print "$1\t"; > print "$2\n"; > } > } > foreach (@SAN) > { > print "Spur roster: $_\n"; > } > > In the end, I want @SAN to have all the unique names > within the file. Any ideas? You just described a Hash. Use %hash and then either uppercase or lowercase the the incoming key. YOu could then add a count to the Hash so you know you are looking at all things or not. The keys for a hash can only appear once(ie, San and SAn are two different keys) that is why you should uppper or lower the keys.
Wags ;) > > __________________________________ > Do you Yahoo!? > Yahoo! Search - Find what you're looking for faster > http://search.yahoo.com Any questions and/or problems, please let me know. Thanks. Wags ;) Int: 9-8-002-2224 Ext: 408-323-4225x2224 ********************************************************** This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. **************************************************************** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>