glob and regex

Discussion in 'Perl' started by Alasdair, Oct 8, 2003.

  1. Alasdair

    Alasdair Guest

    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
    Alasdair, Oct 8, 2003
    #1
    1. Advertising

  2. Alasdair

    Roy Johnson Guest

    (Alasdair) wrote in message news:<>...
    > 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.
    Roy Johnson, Oct 10, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Georgy Pruss
    Replies:
    15
    Views:
    723
    Tim Roberts
    Dec 1, 2003
  2. Tim Peters
    Replies:
    1
    Views:
    356
    Duncan Booth
    Dec 1, 2003
  3. Sean Berry

    Question about glob.glob <--newbie

    Sean Berry, May 4, 2004, in forum: Python
    Replies:
    3
    Views:
    345
    David M. Cooke
    May 4, 2004
  4. Elbert Lev

    glob.glob unicode bug or feature

    Elbert Lev, Jul 31, 2004, in forum: Python
    Replies:
    5
    Views:
    392
    Neil Hodgson
    Aug 2, 2004
  5. Matthew Denner
    Replies:
    1
    Views:
    178
Loading...

Share This Page