in reply to a find question !!!!

ok, iŽll try to be a little more clear i have a dir "/data" with all the patches for a program, but in that dir is also patches for other program. the patches all make there own directories so the patches are in "/data/$patch" and in order for me to get the patch name then i have to do an regex. and last i need to put all the patches into a array
for (`find /data/ -name "*.IND" | grep -E "xxx|yyy"`) ($patch) = ($_ =~ /.*\/(.*)\..*$/); @patch = $patch shift || '.';
I hope that this was more helpful :-) Thanks, Miller

Replies are listed 'Best First'.
Re: A find question !!!!
by Zaxo (Archbishop) on Aug 06, 2001 at 14:58 UTC

    Here is a another way to get them:

    my @patches = grep {/xxx|yyy/} </data/*/*.IND*>; # Above gives the full path to the patches # If you just want the filename, not the full path, use this: #my @patches = map { (split /\//)[-1] } grep {/xxx|yyy/} </data/*/*.I +ND*>;

    Perl grep filters a list down to those elements which leave its first argument true. The diamond operator with glob argument takes care of the file finding.

    After Compline,
    Zaxo

Re: A find question !!!!
by davorg (Chancellor) on Aug 06, 2001 at 14:31 UTC