in reply to using glob to find "unwanted" file names

You're trying to use perl regexen as glob patterns. That doesn't work, as you found. Write those as csh-style shell globs. For instance to pick out names with punctuation, my @badnames = glob( $dir . '/*{!,@,#,$,%,^,&}*'); You may have to play around with the patterns, but you don't need quotemeta. File::Glob takes care of globbing no matter what the platform and the shell is not called.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: using glob to find "unwanted" file names (simpler)
by tye (Sage) on Dec 01, 2003 at 22:40 UTC
    my @badnames = glob( $dir . '/*{!,@,#,$,%,^,&}*'­);

    Can't that be simplified to:

    my @badnames = glob( $dir . '/*[!@#$%^&]*'­ );
    It works for me1.

                    - tye

    1 Though not tested with punctuation characters as I didn't have any files with punctuation in their names for use in my quick test and the nearest operating system sanely refuses to put insane characters into file names.

      Yes, that's certainly better when testing for single characters.

      After Compline,
      Zaxo

Re: Re: using glob to find "unwanted" file names
by Plankton (Vicar) on Dec 01, 2003 at 22:09 UTC
    Ahhh that's much better! Thanks!

    Plankton: 1% Evil, 99% Hot Gas.
Re: Re: using glob to find "unwanted" file names
by Plankton (Vicar) on Dec 01, 2003 at 22:54 UTC
    Hi Zaxo,
    Again thanks ... maybe you can answer this question too?
    I have this now ...
    my @badnames = glob( $dir . '/*{!,@,#,$,%,^,&,\ ,(,),[,|,<,>,;,+,=,`,~ +}*');
    This works fine, but when I try and add ] or } or \ everything matches. I have tried \] \} and \\. The funny thing is that [ { work just fine.

    Plankton: 1% Evil, 99% Hot Gas.