
toolic
User
Sep 24, 2009, 4:44 PM
Views: 1918
|
|
Re: [DoolinDalton] glob and regex
|
|
|
To satisfy your 1st requirement, you could use grep to filter out files with underscores:
@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:
@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:
@files = grep { -f and (! /_/) } glob("C:\\test\\*");
(This post was edited by toolic on Sep 24, 2009, 4:52 PM)
|