in reply to Re: Re: Regexes loaded from file
in thread Regexes loaded from file

Some sort of <code>while(<>){push @subs,eval 'sub{local$_=shift;'.$_.';$_}'}<code>?

Replies are listed 'Best First'.
Re: Re: Re: Re: Regexes loaded from file
by samtregar (Abbot) on May 02, 2002 at 19:03 UTC
    This is correct but not maximally efficient. Why create a separate sub for each s///? It's more efficient to just build one sub containing all the substitutions. Also, why localize and return $_? Operating on it directly is more efficient. See my solution below for an example of what I'm talking about.

    -sam

      I hadn't seen it. And I assumed that he only wanted to read regexes from a file. There it would be more usefull to have them separated. Of course your solution is better in the special situation the whole thread is about. However I read only the note to which I replied. So I chose the more general solution.