in reply to Re^2: Comparing a value to a list of numbers
in thread Comparing a value to a list of numbers
List::Util::uniq() utilizes the hash lookup referred to elsewhere in this thread.use warnings; use strict; use List::Util 'uniq'; my @given = (1,2,5,6,9,10,41..56); my @check = (3,4,9,11,48,102); my $c = uniq(@given); for(@check) { push(@given, $_); print "$_ is in the list\n" unless $c + 1 == uniq(@given); pop(@given); } __END__ Outputs: 9 is in the list 48 is in the list
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Comparing a value to a list of numbers
by LanX (Saint) on Jan 30, 2021 at 20:07 UTC | |
by eyepopslikeamosquito (Archbishop) on Feb 01, 2021 at 04:43 UTC | |
by Anonymous Monk on Feb 01, 2021 at 05:06 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |