in reply to Regexes and /o

Once means once. The regex is evaluated the first time
the line is processed then Perl never checks it again.

The exceptional case is when you use eval
this lets you optimize and be flexible both. You can
get your $regex value as per usual, but use it
inside an eval. This can be a big win.

for ( XXX some loop ) { $patt = gen_patt( $blah); eval 'for $i ( @lines) { if ( $i =~ m/$patt/o){ process( $i); } }'; die "eval error" if $@; }

Replies are listed 'Best First'.
Re: Re: Regexes and /o
by Anonymous Monk on Oct 09, 2002 at 01:05 UTC
    Just wanted to make sure I was getting what I expected, and according to this I am. I was thinking about playing with eval, but I was also attempting to leave it legible as possible for other admins who haven't played with perl as much. I think that going with eval is my next step..

    Thanks for the help