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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions: Re: [DoolinDalton] glob and regex: Edit Log



toolic
User

Sep 24, 2009, 4:44 PM


Views: 3908
Re: [DoolinDalton] glob and regex

To satisfy your 1st requirement, you could use grep to
filter out files with underscores:


Code
@files = grep { ! /_/ } glob("C:\\test\\*");


You need to refine your 2nd requirement
since it contradicts your 1st requirement.

You might be able to wedge something like this
into a grep as well:

Code
@files = glob("C:\\test\\*"); 
@keeps;
for (@files) {
if (($_ eq 'include_file.txt') or (!/_/) ){
push @keeps $_;
}
}


Since glob will also return subdirectoires, you may
also want to grab just files using -f:


Code
@files = grep { -f and (! /_/) } glob("C:\\test\\*");



(This post was edited by toolic on Sep 24, 2009, 4:52 PM)


Edit Log:
Post edited by toolic (User) on Sep 24, 2009, 4:52 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