fionbarr has asked for the wisdom of the Perl Monks concerning the following question:

amended example....fixing typo
my @files = grep ( /[a-z].+\.txt/, readdir($dh));
This does not work.

Replies are listed 'Best First'.
Re: regex to capture files that start with a lowercase letter
by toolic (Bishop) on Feb 13, 2015 at 18:29 UTC
    From your considered post:
    I want to capture *.txt files that begin with a lower-case letter.
    Anchor the pattern:
    my @files = grep ( /^[a-z].+\.txt/, readdir($dh));
      of course, thanks
Re: regex to capture files that start with a lowercase letter
by RichardK (Parson) on Feb 13, 2015 at 18:46 UTC

    But it's still easier to use glob ;)

    my @files = glob('[a-z]*.txt');
Re: regex to capture files that start with a lowercase letter
by Anonymous Monk on Feb 13, 2015 at 18:20 UTC

    Please fix the original post instead of creating new duplicate thread.

Re: regex to capture files that start with a lowercase letter (path tiny)
by Anonymous Monk on Feb 13, 2015 at 22:09 UTC
    readdir is low-level, avoid it , use Path::Tiny
    use Path::Tiny qw/ path /; my @files = path( 'anypath' )->children( qr/^[a-z].+\.txt$/ );