I probably should have specified: the program in my first email is a
minimal sample that can reproduce the problem.  The original program
is significantly longer and more complex.


On Fri, Oct 31, 2008 at 14:38, Li, Jialin <[EMAIL PROTECTED]> wrote:
>
>  print "Match\n" if($target =~ /^$regex$/o);
>
> only compile regex only once

If I understand the "o" regex modifier, that means I can't change the
regex once I've supplied it (so if standard input is

.*target.*
.*testing.*

the program will scan through the list for lines matching "testing" twice).

>
> print "Match\n" if($target =~ /^$regex$/); # can be replace as:
> print "Match\n" if($target eq $regex);
>

This doesn't even do what my sample does, much less the full program.
String equality is not the same thing as substring matching, and
neither can do what the regular expression '.*colou?r.*' does.

-- 
Mark

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to