in reply to Searching file extensions

Not being able to spot a single question mark (bar the regex quantifier) I'm not sure what your question is, so here's some code to find extensions instead
use File::Find::Rule; my @files = find( file => name => [ qw/ *.html *.htm *.pl *.cfm / ], in => @ARGV );
This will recursively search for all files ending in html, htm, pl and cfm in all the directories in @ARGV and then assigning the the resulting list of filenames to @files. See. the ever-handy File::Find::Rule for more info.
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: Searching file extensions
by Anonymous Monk on Jun 19, 2003 at 12:01 UTC
    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?
      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