I have a Perl script that traverses a directory hierarchy using File::Next::files. It will only return to the script files that end in \".avi\", \".flv\", \".mp3\", \".mp4\", a
If you want to build a potentially large regexp and don't want to bother debugging the parentheses, use a Perl module to build it for you!
use strict;
use Regexp::Assemble;
my $re = Regexp::Assemble->new->add(qw(avi flv mp3 mp4 wmv));
...
if ($file =~ /$re/) {
# a match!
}
print "$re\n"; # (?:(?:fl|wm)v|mp[34]|avi)