http://www.perlmonks.org?node_id=1013781


in reply to Re: How to check whether my array contains element x
in thread How to check whether my array contains element x

You might want to change /^$value$/ to /^\Q$value\E$/, especially if $value may contain re metacharacters, but it depends on the application.

while (<>) { chomp; print qr(^$_$), "\t", qr(^\Q$_\E$), "\n"; } __END__ foo (?-xism:^foo$) (?-xism:^foo$) foo[bar] (?-xism:^foo[bar]$) (?-xism:^foo\[bar\]$)

--MidLifeXis