Perl FAQ 5.21: Why do I sometimes get an "Arguments too long" error when I use <*>?

Perl FAQ 5.21

Why do I sometimes get an "Arguments too long" error when I use <*>?

As of perl4.036, there is a certain amount of globbing that is passed out to the shell and not handled internally. The following code (which will, roughly, emulate ``chmod 0644 *'')

    while (<*>) {
        chmod 0644, $_;
    }

is the equivalent of

    open(FOO, "echo * | tr -s ' \t\r\f' '\\012\\012\\012\\012'|");
    while () {
        chop;
        chmod 0644, $_;
    }

Until globbing is built into Perl, you will need to use some form of non-globbing work around.

Something like the following will work:

    opendir(DIR,'.');
    chmod 0644, grep(/\.c$/, readdir(DIR));
    closedir(DIR);
    
    This example is taken directly from ``Programming Perl'' page 78.

If you've installed tcsh as /bin/csh, you'll never have this problem.


Other resources at this site: