ketema has asked for the wisdom of the Perl Monks concerning the following question:
Is it possible to make an assignment of one scalar if a match is found in the elements of an array,
in a single statement? I'm sure this syntax is wrong, but something like:
in a single statement? I'm sure this syntax is wrong, but something like:
I know the regular expression part is wrong, but is there some advanced Monk way of accomplishing this? What about grep? can that somehow be incorporated into the regex?@terms = ("Word1","Word2","Word3"); $match = $1 if($lineFromSomeTextFile =~ /(^@terms)/);
Back to
Seekers of Perl Wisdom