perlquestion
Zoogie
I need to get a list of files that fit a set of filename
globs input by the user. The problem is, the files may
be in a different directory. For example, if the user
enters:<p>
<pre>
$area = "public/test/";
@files = ("*.txt", "_*");
</pre>
The function should return something like:<br>
<pre>
readme.txt, files.txt, _index, _sortopts, ... etc.
</pre>
I'm trying to use the glob function, but if you specify
another directory, that directory name is prepended to
every filename. Here's my current function:<p>
<pre>
@file_list =
map { /^$area(.*)/; $1 }
glob(join(' ',map { $area.$_ } @files));
</pre>
Works as expected, but that seems like a lot more work
than necessary. Is there an easier / clearer / more
efficient way to do this?