Home > Archive > PERL Miscellaneous > April 2004 > Newbie : How to exclude particular files from glob()?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Newbie : How to exclude particular files from glob()?
|
|
| Abhinav 2004-04-27, 10:01 am |
| 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
| |
| Christian Winter 2004-04-27, 12:14 pm |
| Abhinav schrieb:
> 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 .. ?
I don't know csh very well, so maybe there's a really simple
solution using standard glob syntax, but I'd do it like this:
my @x = grep !/^Master/, <*>;
HTH
-Christian
| |
| Glenn Jackman 2004-04-27, 12:14 pm |
| Abhinav <matrix_calling@yahoo.dot.com> wrote:
> 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/, <*>;
--
Glenn Jackman
NCF Sy min
glennj@ncf.ca
| |
| Abhinav 2004-04-27, 12:14 pm |
| Hi Glenn/Christian,
Glenn Jackman wrote:
> Abhinav <matrix_calling@yahoo.dot.com> wrote:
>
>
>
> One way is to filter the list of all files:
> my @x = grep !/^Master/, <*>;
>
Thanks !
Regards
Abhinav
|
|
|
|
|