Just another Perl shrine | |
PerlMonks |
variables in regex character classesby amir_e_a (Hermit) |
on Jul 22, 2006 at 19:32 UTC ( [id://563037]=perlquestion: print w/replies, xml ) | Need Help?? |
amir_e_a has asked for the wisdom of the Perl Monks concerning the following question: Hello, Consider this code:
The substitution looks for words that begin with any of @all_words and end with zero or more of $BEL_LETTERS. This code doesn't compile. Problem: the compiler thinks that $next_word[$BEL_LETTERS] is member $BEL_LETTERS of array @next_word. This works - notice the parentheses:
...But it feels like a hack to me. Is there a better way to overcome this interpolation? I tried searching for the answer here in Q&A and in the Camel book, and strangely couldn't find it. I'm quite sure that the answer must be in the book, and if someone can point it to the page i'll be very thankful too. (If anyone is curious, this code is looking for pronouns in a Belarusian text. This example here is very simplified - i didn't want to put the whole Belarusian-Cyrillic alphabet here).
Back to
Seekers of Perl Wisdom
|
|