in reply to YAREGEX for all

How about:
if ($fs =~ /^(?i)\/data\w+$/ || $fs =~ /^(?i)\/tmp\w+$/ ) {

The difference is the $fs after the ||. Your code compares the 2nd regex against $_.

If that doesn't do it, please show some examples of values of $fs.

Update: Here is a small example:

#!/usr/bin/env perl use warnings; use strict; while (my $fs = <DATA>) { if ($fs =~ /^(?i)\/data\w+$/ || $fs =~ /^(?i)\/tmp\w+$/ ) { print "match: $fs"; } } __DATA__ junk /tmp /tmpfoo /data /data2 /data again junk2

This prints:

match: /tmpfoo match: /data2

Replies are listed 'Best First'.
Re^2: YAREGEX for all
by mikejones (Scribe) on Apr 22, 2008 at 20:29 UTC
    yes I tried that just after I posted....too funny! thanks! Ok but now my question is, is | more efficient that ||?

      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.

      | 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