Jay Savage wrote: > > I've actually found it depends partly on architecture, too; the regex > engine seems better optimized on some platforms than others. I was > quite surprised once when benchmarking a script on a fairly modern OS > X/PPC machine (750MHz CRT iMac) and an ancient Linux box (166MHz PII > Dell Dimension XPS PII running SuSE 9.1)--with both machines running > 5.8.6--that the regex solution to the problem I was working on ran > faster on the the Dell, but the index version ran faster on the Mac. > > The issue seemed to be the number of function calls. index beat the > pants off m// on both machines for finding literals, of course, but > once I had to perform two indexes, combining them both into a single > regex ran faster on one machine and was only about 1% slower on the > other. > > The relevance here is that once your looking for several things, I'd > at least want to bechmark the regex, especially since we're firing up > the regex engine for the first match anyway. > > My advice to the OP would be to benchmark all three of the following > and see which comes out on top for him: > > grep /_${feed_date}_.*?\.wav\z/o, @dir_files; > grep ((index($_, $feed_date) != -1) && (index($_, ".wav") != -1)), > @dir_files; > grep /\.wav\z/ && (index($_, $feed_date) != -1), @source_list; > grep { /_${feed_date}_/ && /\.wav$/ } @dir_files;
Be careful with those matches to ensure you are matching the same things. For example, the OP said he had file names something like: ABCD_9Mar_somethingelse.wav ABCD_19Mar_somethingelse.wav If $feed_date is '9Mar' then your second and third examples will match both file names and your second example will also match the file name: ABCD_9Mar_some.wavthingelse.pdf John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>