in reply to perl's glob function - argument passing

If you read the glob documentation, you see that it is implemented (since perl 5.6) by File::Glob. There, you read that it's implemented "in terms of" File::Glob's bsd_glob routine. But apparently there's a functional difference between glob and bsd_glob: the former considers its argument to be one or more whitespace-sepearated patterns, whereas the latter considers it a single argument, even if it includes whitespace. So I wonder: does this long path you have contain any spaces? If so, try loading File::Glob and using its bsd_glob routine instead.

Another avenue would be to try another module which provides an alternative glob, such as File::DosGlob and FastGlob. (All these modules let you override the core glob with their version, if you want.)

A word spoken in Mind will reach its own level, in the objective world, by its own weight

Replies are listed 'Best First'.
Re^2: perl's glob function - argument passing
by bart (Canon) on Jan 17, 2007 at 12:20 UTC
    That's only part of the story.

    Even though I'm no C expert, I did some hunting around in the internals of File::Glob. bsd_glob calls doglob. In addition, the module uses XSLoader, so, it's an XS module. :) Looking at the current source of Glob.xs, doglob in turn calls the C function (not an XS function) bsdglob, which in turn can be found in bsd_glob.c. In turn, that calls the C function glob0, in the same source file. Are you still with me? Now the documentation for glob0 says:

    /* * The main glob() routine: compiles the pattern (optionally processin +g * quotes), calls glob1() to do the real pattern matching, and finally * sorts the list (unless unsorted operation is requested). Returns 0 * if things went well, nonzero if errors occurred. It is not an erro +r * to find no matches. */
    So, it appears to be the "main routine".

    Now, and this is the interesting part: it allocates buffers with a length MAXPATHLEN. This constant is defined in perl.h, and it's platform dependent. Anyway, usually this constant is an IMO rather small number, as the code comments there state:

    # define MAXPATHLEN 1024 /* Err on the large side. */
    Note the comment: 1024 is considered "large".

    Now, to answer the OP's question: yes, it looks like there's a built in limit on the length of the strings that glob will return, but the exact maximum value depends on your platform.

    And I'm not sure I did all of my homework well, I might still have overlooked something essential.