in reply to glob and regex

It's not clear what you are actually doing. You have a regex, but you are also talking about globs. What are you doing with the glob? What are you matching against what, and what matches and what doesn't? /[A-Za-z]{2}_\w{2,5}/ matches any string that contains two letters (either case), followed by an underscore, followed by at least 2 word characters.

But that's a regex, not a glob.

Abigail

Replies are listed 'Best First'.
Re: Re: glob and regex
by dragonchild (Archbishop) on Oct 09, 2003 at 16:22 UTC
    According to Camel (3rd) on p. 85, it says:
    @files = glob $some_pattern; # Call glob as an operator.

    When I first read that, I thought $some_pattern meant $some_regex. But, it doesn't. (Or, rather, it does mean $some_regex, but it means to use a regex with a different syntax than Perl's regex syntax.)

    What the OP is looking for probably falls under the category of:

    my @files = grep { /[A-Za-z]{2}_\w{2,5}/ } glob "??_??";

    Two different regex syntaxes. *shrugs*

    ------
    We are the carpenters and bricklayers of the Information Age.

    The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.