http://www.perlmonks.org?node_id=1053514


in reply to Multiple Conditional Statements

...and a recursive option with error tolerant comparison...

use strict; use warnings; my $eps = 1e-10; sub distinct { return 1 if @_<2; # lists of 1 or empty lists never have dupli +cates my $first = shift; for( @_ ) { return 0 if abs($first - $_)<$eps; } return distinct( @_ ); } my @n = ( 1, 2, 3, 4, 4 ); print distinct( @n );