in reply to Re: Pulling a file with a given extension
in thread Pulling a file with a given extension
#!/usr/bin/perl use strict; use warnings; use Benchmark qw( cmpthese ); sub globber { return(( glob '*.xml')[0]); } sub opener { opendir my $dir, '.'; my $file; while (defined($file= readdir $dir)) { last if $file=~ /\.xml$/; } closedir $dir; return $file; } cmpthese(5000, { globber => \&globber, opener => \&opener, });
Rate globber opener
globber 654/s -- -76%
opener 2688/s 311% --
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Pulling a file with a given extension
by Tanktalus (Canon) on Oct 18, 2005 at 18:46 UTC |