On Wed, Jul 23, 2003 at 03:25:53PM -0500, Dan Muey wrote: > That must be in perldoc sine you both had the same example > but I couldn't find it and the perldoc your recommended Bob > couldn't be found! > > I like this very much and I'm assuming it's faster than > putting them in hash and returning the keys as an array > since you don't have to build a hash.
Actually you *do* build a hash. :-) > @unique = do { > my %seen; > grep !$seen{$_}++, @arr > }; The advantages are that (a) it doesn't change the order of the input array and (b) it's a common idiom that the next programmer in line will recognize instantly. The hash-keys version would probably be a bit faster: @unique = keys %{ my %set; @set{ @arr } = (); # fast! \%set; }; But karma is more important than (a smidgen of) speed. -- Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]