
DoolinDalton
Novice
Sep 24, 2009, 2:41 PM
Post #1 of 4
(8190 views)
|
glob and regex
|
Can't Post
|
|
I have the following very simple code. @files = glob("C:\\test\\*"); $file_count = @files; print $file_count; As you can see, I am globbing everything in the directory C:\test and printing the count of the files. How do I utilize regex to modify the parameter of the glob so that... (1) I exclude any files that containt the underscore character ( "_" ) (2) But include certain specific files that have the underscore character. For example, if the file list in the directory was file1.txt file_2.txt file3.txt include_this_file.txt Then I want to print 3. (Eventhough the last file has the underscore character, I want to include this in the glob.) I would guess, somewhere in the regex I would need to hard code the files I want, in this case, the file called include_this_file.txt.
(This post was edited by DoolinDalton on Sep 24, 2009, 2:43 PM)
|