While it is very slightly less efficient as it needs to be compiled, the regex engine will see it is dealing with a fixed string and use shortcuts rather than generic pattern matching, so that will only matter in a tight loop processing a lot of data. However I find it reads a lot more naturally.my @array = qw ( a b c d x ); my $sought = 'a'; print 'Found!' if "@array" =~ /\Q$sought/;
Makeshifts last the longest.
In reply to Re: Is X in my array?
by Aristotle
in thread Is X in my array?
by Not_a_Number
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |