in reply to Is X in my array?
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.
|
|---|