#!/usr/bin/perl use warnings; use strict; my @values = qw/banana plum apple strawberry pea/; my $var = 'apple'; my %hash; undef @hash{@values}; print exists $hash{$var} ? "yes\n" : "no\n"; print +(grep $_ eq $var, @values) ? "yes\n" : "no\n";
In reply to Re: check if a value is in a given set
by choroba
in thread check if a value is in a given set
by Ratazong
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |