/a-z.+\.txt/
If /[a-z].+\.txt/ is the regex you're using (a bit difficult to tell because you don't use <code> ... </code> tags), then it will match a string with a lower-case letter anywhere in it, followed by one or more of anything except a newline, followed by '.txt' and then followed by anything. I recommend using string anchor assertions (untested):
my @files = grep m{ \A [a-z] .* \.txt \z }xms, readdir $dh;
(which also allows for single-letter file names). Please see perlre, perlrequick, and perlretut.
Give a man a fish: <%-(-(-(-<
| [reply] [d/l] [select] |
I believe the issue is that you are not denoting that a-z is a sequence. See:
http://perldoc.perl.org/perlre.html
Try this:
@files = grep ( /[a-z].+\.txt/, readdir($dh));
Please note, this will not match filenames with a single letter. If you intend to match on a file name a.txt, then you need to chnge the + to *.
Hope that helps. | [reply] [d/l] |