One, perhaps final, comment. In the process of writing a short program to reproduce the behavior (in case someone, probably me, decides to file a bug report, my earlier whinging notwithstanding), I came up with this:
#!/usr/bin/perl -w
use strict;
use File::Glob ':glob';
my $dir = shift || "/etc";
my $max = shift || 10000;
my $entries = 0;
while (glob("$dir/*")) {
last if (++$entries > $max);
}
print($entries, " items under $dir\n");
If I comment out the use File::Glob ':glob'; to get a run with the core glob, then put it back in, I see the following
time globbug.pl /etc 20000
279 items under /etc
real 0m0.00s
user 0m0.00s
sys 0m0.00s
time globbug.pl /etc 280
281 items under /etc
real 0m0.15s
user 0m0.09s
sys 0m0.06s
The first (core) run demonstrates that there are 279 entries in my /etc, and it takes almost no time to determine that. The second run, confined to stop after it is demonstrably wrong, takes quite a while to be wrong. This is consistent with it rebuilding the entire list for each iteration, then throwing away all but the last item.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|