in reply to pattern match -vs- *ix grep

Adding an 'o' to the end of the regexp avoids the pattern being recompiled each time round the loop, ie
if (/$pattern/o) {

Dave.

Replies are listed 'Best First'.
Re^2: pattern match -vs- *ix grep
by Anonymous Monk on Apr 07, 2005 at 16:39 UTC
    That only matters if either the pattern changes (which it doesn't), or you have a really, really ancient perl.

    For the past several years, Perl knows the pattern hasn't changed, and will not recompile the regex. (Use -Dr if you're not convinced).

      Ah yes, silly me. It bypasses the calls to the gvsv and regcomp ops though, so there's still a marginal saving.

      Dave.