Check out the
glob function, which expands filenames with wildcards.
kiyohara put this to use in a Win32 prog in the Craft entry
GlobArgv. Also take a look at the
study function and its documentation. You may be able to speed up your query, and the doc has a grep-like code sample at the bottom: two for one! :-) I believe more than a few versions of grep have already been coded in Perl (with varying complexity, of course), so take a look around the web to avoid reinventing the wheel.