in reply to Re: Slow Regex - How to Optimize
in thread Slow Regex - How to Optimize

That's not true. m/.../ only recompiles if the contents of any interpolated variable has changed. Demo:

use re 'debug'; foreach (qw( abc abc def )) { print("==============================\n"); print("$_\n"); print("\n"); /$_/; }

Update: Oops, I didn't notice you reversed the loops in addition to moving the regexp.