Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Pattern matching

Status
Not open for further replies.

imad77

Instructor
Oct 18, 2008
97
CA
Hi,

I experience some issues to list the files with a pattern matching in Perl. I want to exclude the files beginning by "abc" or "ppt" or "jac". But I experience some issues to exclude some files or to list some other files that are not concerned by this exclusion.
I use a pattern like : $sf="abc|ppt|jac";

Have any idea to put a correct pattern?

Thanks a lot.
=======
Here is my script:

opendir(DIRS, "$direc");
@list1 = readdir(DIRS);
closedir(DIRS);

my $sf="abc|ppt|jac";
foreach(@list1){
unless($_ eq '.' || $_ =~ m/^$sf*/){
push(@list2, $_);
}
}

foreach my $file (@list2){
print "$file\n";
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top