http://qs321.pair.com?node_id=589972


in reply to Re: without looping, check if $var is found in @list
in thread without looping, check if $var is found in @list

Using string interpolation on the array is a bad idea - it won't neccessarily get you what you want. For example:
#!/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"; }
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...