I'd like to know why globbing is so much slower than readdir. Sure, that makes sense for really old versions of Perl (where the slowness of glob is insignificant to the security problems of it).
I could even see glob being slightly slower than readdir, such that you likely wouldn't notice the difference, especially in a script (like your example) that does something other than list file names.
But you say using glob makes your whole script a lot slower ("impressive"). What I, as a Perl programmer, would like to know, is some estimate of how much slower glob is than readdir. How about some numbers based on what you saw as one source of data? You said over 4000 files and show the contents of the files being read. How long did the different versions take? About how large were the files you were reading?
I often prefer glob as it often makes for less code (and has fewer 'gothca's). But if it is hugely slower, then I'll prefer it less often.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||