Newbie : How to exclude particular files from glob()?

A

Abhinav

Hi

I need to do an glob on a Directory, but exclude a set of particular
file starting with "Master" .

Using

my @x = <[!M][!a][!s][!t][!e][!r]*>;

is definitely wrong ..It omits files such as "Faster" too ..

What is the correct way to do it .. ?

Thanks
Abhinav
 
G

Glenn Jackman

Abhinav said:
Hi

I need to do an glob on a Directory, but exclude a set of particular
file starting with "Master" .

Using

my @x = <[!M][!a][!s][!t][!e][!r]*>;

is definitely wrong ..It omits files such as "Faster" too ..

What is the correct way to do it .. ?

One way is to filter the list of all files:
my @x = grep !/^Master/, <*>;
 
A

Abhinav

Hi Glenn/Christian,

Glenn said:
Abhinav said:
Hi

I need to do an glob on a Directory, but exclude a set of particular
file starting with "Master" .

Using

my @x = <[!M][!a][!s][!t][!e][!r]*>;

is definitely wrong ..It omits files such as "Faster" too ..

What is the correct way to do it .. ?


One way is to filter the list of all files:
my @x = grep !/^Master/, <*>;
Thanks !
Regards
Abhinav
 

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,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top