Hi Darren, -----Original Message----- > I'd like to remove duplicate values from an array to leave it with only > unique values. For instance, if an array contains (1,2,3,1,4,2,5) as > values, I'd like to clean out the extra 1 and 2 to leave the values as > (1,2,3,4,5). Does perl have an array command to do that, or must the > process be purely manual?
This is a FAQ, you can bring it up at perldoc -q "duplicate" In short, there is no built-in way to do this. The hash is the usual method for disallowing duplicates (in the keys). The most elegant solution from the FAQ is (in my opinion) to use hash slices to avoid a loop: @duparray = (1..10, 1..10); @[EMAIL PROTECTED] = (); @uniquearray = sort keys %tmphash; Hope this helps. Thanks Matt Shaw xwave, An Aliant Company Desk: 506-389-4641 Cell: 506-863-8949 [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>