in reply to precompiling regular expressions

If $string2 does not change during each and every indivudual run of the script, then adding the o (mnemonic: once) modifier will be advisable. The regex will then be compiled only once.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: precompiling regular expressions
by Anonymous Monk on Oct 22, 2010 at 02:58 UTC
    sadly string2 does change after some thousends or millions of uses, so I can't use /o in most cases