in reply to Finding files excluding some

This is only slightly tested but I think it's right-

use File::Find::Rule; my @files = File::Find::Rule->file() ->not( File::Find::Rule->new->name("*.[!ao]") ) ->in("."); print join("\n", @files), "\n";

File::Find::Rule. Much easier interface than File::Find (update: fixed backwards names).

(update: thanks to afoken below; ("*.[!ao]") should not have the bang: ("*.[ao]"), and merlyn's example is probably more in line with what you're after.)

Replies are listed 'Best First'.
Re^2: Finding files excluding some
by afoken (Chancellor) on Mar 30, 2009 at 23:21 UTC
    ->not( File::Find::Rule->new->name("*.[!ao]") )

    I think there should be only one negation. As only *.a and *.o should be ignored, the inner rule should be ...->name('*.[ao]').

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)