in reply to File name filtering with ^ ?

Rory.

Thanks for posting :)

^ signifies the beginning unless you're inside of square brackets, in which case (as cdarke pointed out) it means 'not'.

What you're probably looking for is something like:
my @files = () ; opendir DIR, '/path/to/dir' ; foreach( readdir DIR ){ # do this unless it matches a digit or char followed by T # or V followed by anything. push @files, $_ unless/[\d\w][TV].*/ ; }
Bro. Doug :wq

Replies are listed 'Best First'.
Re^2: File name filtering with ^ ?
by xicheng (Sexton) on Mar 20, 2007 at 05:50 UTC
    [\d\w] is the same as \w, and adding an anchor to the regex pattern might be more efficient:
    
       push @files, $_ if /^\w[^TV]/; 
    
    or simply:
    
       my @files = grep {/^\w[^TV]/} glob("*.pl");
    
    or try shell to negate the character-class:
    
       my @files = glob("h[!TV]*.pl");
    
    Regards, 
    Xicheng