in reply to Re: YAREGEX for all
in thread YAREGEX for all

yes I tried that just after I posted....too funny! thanks! Ok but now my question is, is | more efficient that ||?

Replies are listed 'Best First'.
Re^3: YAREGEX for all
by chromatic (Archbishop) on Apr 22, 2008 at 20:34 UTC

    Sometimes, but if these are file paths and you're doing IO, you're not going to see any time difference at all in your program. Consider using the most maintainable code in this case.

Re^3: YAREGEX for all
by runrig (Abbot) on Apr 22, 2008 at 20:35 UTC
    | and || are different operators. See perlop.
      I think he meant /abc|def/ versus /abc/ || /def/


      Unless I state otherwise, my code all runs with strict and warnings
        correct I meant  /abc|def/ versus /abc/ || /def/

        I think I will use this code. Goal is to match whats under __DATA__ and it seems to work.

        Comments? thank you!

        use warnings; use strict; while (my $fs = <DATA>) { if ($fs =~ m{(?i)^/(?:oracle|db|db2|informix|data)(?:\s+\z||\s+\w+ +\z)} ) { print "match: $fs"; } } __DATA__ junk /oracle /db /db2 /informix /data again/debo junk2 /oracle/foo /db/foo /db2/foo /informix/debo/