The . (dot) in your regular expression will match anything. You need to escape it, i.e.

$folder =~ /(\d{6}\.?\d{2}?\w?)/;


Also, this regular expression is matching for files which are of the form ######## (8 numbers without a dot), and files of the form ######a (6 numbers and the optional letter), as well as a few other forms that it sounds like you don't awnt to capture. Is the optional 2 digit number and letter dependent on whether there is a dot? If so, you are going to need a slightly more complex regular expression.

One last question, why do you even have the regular expression in there? Can't you use $folder instead of $1 without loss of generality? You aren't doing a conditional based on whether or not the regexp matches, so I assume all folders are meant to be replaced in...

In reply to Re: Regular Expression Question by swkronenfeld
in thread Regular Expression Question by MistaMuShu

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.