in reply to Re: without looping, check if $var is found in @list
in thread without looping, check if $var is found in @list
happily reports a match even though just "turtle" doesn't appear in the array, it's a "jumping turtle". I would be reluctant to assume that such behavior is desirable...#!/usr/bin/perl -w use strict; use warnings; my @list = ('jumping turtle', 'frog', 'tadpole'); my $var = "turtle"; if ("@list" =~ /\b$var\b/) { print "yup\n"; }
|
---|