glob and regex

A

Alasdair

Hi,
I have a problem using regular expresions and the glob operator.
I want to get files with a specific name format from a directory using
glob. The regular expresion I use to match the name format is
/[A-Za-z]{2}_\w{2,5}/

Any suggestions on how to get this regular expression into glob much
appreciated

Alasdair
 
R

Roy Johnson

I want to get files with a specific name format from a directory using
glob. The regular expresion I use to match the name format is
/[A-Za-z]{2}_\w{2,5}/

It would probably be best to use opendir and readdir to get all the
filenames, and filter them yourself. Like:

opendir D, '.' or die "Could not open current dir: $!\n";
my @filelist = grep(/[A-Z]{2}_\w{2,5}/i, readdir D);
closedir D;

Converting your regex to a glob ex is cumbersome.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,279
Latest member
LaRoseDermaBottle

Latest Threads

Top