#! perl -slw use strict; use Benchmark qw[ cmpthese ]; use File::Find; our( $dir, $glob, $re_glob ); my %tests = ( GLOB => q[ my $count; $count++ while <${dir}/${glob}>; print 'GLOB: ', $count; ], FIND => q[ my $count; find( sub{ m[$re_glob] and $count++ }, $dir ); print 'FIND: ', $count; ], ); ( $dir, $glob, $re_glob ) = ( 'bigdir', '/*.txt', qr[\.txt$] ); cmpthese( 3, \%tests ); ( $dir, $glob, $re_glob ) = ( 'bigdir', '*A.txt', qr[A\.txt$] ); cmpthese( 10, \%tests ); __END__ P:\test>glob-ff FIND: 17576 FIND: 17576 FIND: 17576 GLOB: 17576 GLOB: 17576 GLOB: 17576 s/iter FIND GLOB FIND 29.6 -- -1% GLOB 29.4 1% -- FIND: 676 FIND: 676 FIND: 676 FIND: 676 FIND: 676 FIND: 676 FIND: 676 FIND: 676 FIND: 676 FIND: 676 GLOB: 676 GLOB: 676 GLOB: 676 GLOB: 676 GLOB: 676 GLOB: 676 GLOB: 676 GLOB: 676 GLOB: 676 GLOB: 676 s/iter FIND GLOB FIND 29.6 -- -87% GLOB 3.97 646% --