Could you give a bit more details about just what those
/..../ bits really are?
- Are they constant? (i.e. /abcd/, not containing any interpolated variables; if so then they'll be compiled once
and you don't have anything to worry about (just covering
that base because of the vagueness))
- Do they depend on something determinied at runtime, but
that doesn't vary from line to line? If so, then compile
them once with a $res = prepare_regexen() that populates a hash; then use if( m/$res->{CONDITION_ONE} / ) { ... }
- Do they vary from line to line? In this case you're
probably screwed, but you might can make gains by factoring
out common subexpressions and precompiling those.
- Consider whether you really need regular expressions,
or if you can replace some with index instead.