As was already pointed out, this if ($var =~ /^[qw(Smith Jones Schmidtz)]/) doesn't work as it just creates a character class equivalent to [SmithJonescdz] - which just compares to the first character of $var. Two solutions:
my @names = qw(Smith Jones Schmidtz); my $pattern = join '|', @names; if ($var =~ /^(?:$pattern)/) # or quicker if ($var =~ /^Smith/ || $var =~ /^Jones/ || $var =~ /^Schmidtz/)
-- Hofmator
In reply to Re4: Is there an InString-like function?
by Hofmator
in thread Is there an InString-like function?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |