Perl glob performs lstat
Avoid the quick glob function if no lstat related data will be used, as glob performs an lstat on each matching file. Instead, use opendir and readdir to efficiently work through many filenames, or a module such as File::Find to recurse through a directory tree.
Use ktrace(1) or similar process tracing utility to see the lstat calls done by glob in Perl. See Unix Debugging Tips for more information on ktrace and similar tools.
$ ktrace perl -e 'glob("*")' $ kdump -f ktrace.out | grep -5 lstat | head 7355 perl RET __sysctl 0 7355 perl CALL fstatfs(0xd,0xbfffc564) 7355 perl RET fstatfs 0 7355 perl CALL getdirentries(0xd,0x1811200,0x1000,0x306b94) 7355 perl RET getdirentries 460/0x1cc 7355 perl CALL lstat(0xbfffc620,0xbfffca80) 7355 perl NAMI "critic.t" 7355 perl RET lstat 0 7355 perl CALL lstat(0xbfffc620,0xbfffca80) 7355 perl NAMI "encrypt-and-sign.sh"
On the other hand, the implicit lstat caches the file metadata for quick lookup with stat _:
$ perl -le 'for (glob("*")) { print "$_ ", (stat _)[9] }' …