Fellow Monks:
I need help 2 fold with regular expressions, for I realize they are exceptionally useful, but, unfortunately even the simplest aspects, as seen in my code snippet below, confound me.
First: What I would like to do is conduct a directory listing, (not a problem), and match into a directory via grep files that meet only the following criteria: match the front part of the filename, a fixed string, and the back part of a filename, essentially a fixed extention; where AAAAAnnnnn.txt; AAAAA is the front half of the filename that is fixed, to be matched; nnnnn is the part of the filename the changes and .txt is the fixed extension.
the code attempt (a snippet):
my $datadir="/user1/localfiles/data/" opendir LOCALDIR, "$datadir" or die "unable to open $datadir\a\n"; my @localfiles=grep/(^file-15a_62_200405)&&(.txt$)/i readdir LOCALDIR; foreach my $file(@localfiles) { print "$file\n"; }
shown above is my blind (lack of knowledge) attempt which obvoiusly didn't work. Originally the grep line was just set to match just the extension,
my @localfiles=grep/.txt$/i readdir LOCALDIR;
or I could match the beginning with:
my @localfiles=grep/^file-15a_62_200405/i readdir LOCALDIR;
which worked just fine. In a nutshell.... I simple do not know how to combine the two. I would really appreciate your help in this matter and I humbly thank you in advance.
The Second Part:
My first thought was to look for tutorials on regular expressions, I googled and found a list longer than my arm. Are there any recommended tutorials for regular expressions favored among the community? I am looking for simplicity and practical application of regexes..... something to start me out from the very beginning.... again many thanks.

In reply to Simple Regular Expression Help Needed by PerlBear

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.