Because I always forget it, here as a reminder for me: How does perl's grep work:
grep {BLOCK} ARRAY;
or rather
grep (EXPR, ARRAY);
example:
@sesamestreet = ("b-bird", "ernie", "bert", "elmo");
$yeah_no = "";
if(!grep{$_ eq $ARGV[0]} @sesamestreet){
$yeah_no = "not ";
}
print "$ARGV[0] is ".$yeah_no."in sesamestreet\n";
Commenting is closed for this article.