http://www.perlmonks.org?node_id=129267


in reply to subroutine within regex quantifier?

while ( $target_letters !~ /^[a-z]{$Word_Length}$/i ) { ...
Whether you find a way to use WORD_LENGTH directly or not, you might wish to ensure that the regex is compiled exactly once. /o is your friend.