I have array @hon_data. If any elements of the array are one of a known list of values, I return zero.
for my $hon_field (@hon_data) {
if($hon_field ne 'B' and $hon_field ne 'S' and $hon_field ne 'G' and
$hon_field ne 'D' and $hon_field ne 'L') {
return 0;
}
}
The number of values to check is growing, so this approach is getting complicated to manage. Is there a way to do this with the values in an array?
my @results =("B","G","S","D","N","L");
my @results2 = ("A","G","S","D","N","L");
sub uniq {
my %seen;
grep { !$seen{$_}++ } @_;
}
my @unique = uniq(@results, @results2);
In result2 A is unique value and it should return A only But this code is not working.