in reply to Re: Search array of file names in directory structure
in thread Search array of file names in directory structure
or, if you like things done in 1 shot,my $regex = do { my @escaped; push @escaped, quotemeta for @filelist; my $joined = join '|', @escaped; qr/^(?:$joined)$/; };
or, for the overly clever, my $regex = qr/^(?:@{[join '|', map quotemeta, @filelist]})$/;my $regex = '^(?:' . join('|', map quotemeta, @filelist) . ')$';
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Search array of file names in directory structure
by Kenosis (Priest) on Oct 01, 2012 at 18:56 UTC | |
by kennethk (Abbot) on Oct 01, 2012 at 20:09 UTC | |
by Kenosis (Priest) on Oct 01, 2012 at 20:23 UTC |