> -----Original Message-----
> From: Mooney Christophe-CMOONEY1 [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 31, 2001 9:44 AM
> To: [EMAIL PROTECTED]
> Subject: RE: check array element (HELP)
>
>
> I would probably do this, although i'm sure some smarty-pants
> could come up with a one-liner ;)
>
> sub repeated_elements
> {
> my %found_one;
> for (@_)
> {
> return 1 if $found_one{$_}++;
> }
> return 0;
> }
One-liner:
print "Duplicates!" if keys %{{ map { ($_ => 1) } @arr }} != @arr;
Note: Do NOT use this! Along with being quite unreadable, it's also
inefficient. Use the iterative approach above.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]