CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Regular Expressions: glob and regex: Edit Log


Sep 24, 2009, 2:41 PM

Views: 5280
glob and regex

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


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)

Edit Log:
Post edited by DoolinDalton (Novice) on Sep 24, 2009, 2:43 PM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives