in reply to Re: Searching file extensions
in thread Searching file extensions

My question is how can I put all four of the extensions in my search?
if( $_ =~ /\.html?$/ or \.cfm/ or \.pl/)
Basically get it to search for all four in my "if( $_ =~ /\.html?$/ or \.cfm/ or \.pl/)" part. I dont think I can put "or" in my search part so how else can I do it?

Replies are listed 'Best First'.
Re: Re: Re: Searching file extensions
by broquaint (Abbot) on Jun 19, 2003 at 12:05 UTC
    A simple use of grouping and alternation should do the trick e.g
    print "$_ - ", ( /\.(?:html?|cfm|pl)$/ ? "yep" : "nope" ), "\n" for qw/ foo.pl bar.cfm baz.htm quux.xxx /; __output__ foo.pl - yep bar.cfm - yep baz.htm - yep quux.xxx - nope
    See. perlre for more info on regexes.
    HTH

    _________
    broquaint